-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.lang.NullPointerException when iteration through viewentrycollection #186
Comments
Hi, we reported a suppport case at HCL and according to their findings the OpenNTF code is not threadsafe. Here is a snippet of their report: While review the logs its not HTTP task related issue however this issue with a multi-threaded application code and issue seems to happen in the openntf framework and custom code use.
|
so same issue on iterating through viewentrycollection as documentcollection |
Custom code used: -
|
Release 12.0.1FP1 HF72 server release |
the java class that causes nullpointer exception package org.acme.kkom.dao; import java.io.File; import javax.faces.context.FacesContext; import org.apache.commons.io.FileUtils; import com.ibm.commons.util.io.json.JsonException; import org.acme.kkom.app.ApplicationBean; public class AttachmentDominoDAO implements AttachmentDAO, Serializable{
} |
Are you able to reproduce the trouble in a minimal case? To try to see it here, I:
package bean;
import org.openntf.domino.Database;
import org.openntf.domino.Session;
import org.openntf.domino.View;
import org.openntf.domino.ViewEntryCollection;
import org.openntf.domino.ViewEntry;
import org.openntf.domino.utils.Factory;
import org.openntf.domino.utils.Factory.SessionType;
import com.ibm.xsp.extlib.util.ExtLibUtil;
public class BeanGuy {
public String doFoo() {
Session session = Factory.getSession(SessionType.CURRENT);
Database database = Factory.getWrapperFactory().fromLotus(ExtLibUtil.getCurrentDatabase(), Database.SCHEMA, session);
String key = "";
View vw = database.getView("Docs");
if (null != vw){
vw.setAutoUpdate(false);
ViewEntryCollection entries = vw.createViewEntryCollection();
if (null != key) {
if(!key.isEmpty()){
entries = vw.getAllEntriesByKey(key,true);
} else {
entries = vw.getAllEntries();
}
} else {
entries = vw.getAllEntries();
}
for (ViewEntry entry : entries) {
if(!entry.isCategory()){
System.out.println(entry.getColumnValues());
}
}
vw.setAutoUpdate(true);
}
return session.toString();
}
} In my case, this worked fine (regardless of whether or not I filled I'll attach my minimal NSF here: |
My apologies, I was out of office for home renovation. I have tested the NSF and I have no problems running the foo xsp |
Do you also get the NPE error if you use |
here is an example of the error from log.nsf:
java.lang.NullPointerException
2023-05-26 09:44:29 HTTP JVM: at org.openntf.domino.impl.ViewEntryCollection.getCount(ViewEntryCollection.java:219)
2023-05-26 09:44:29 HTTP JVM: at org.openntf.domino.iterators.ViewEntryIterator.(ViewEntryIterator.java:57)
2023-05-26 09:44:29 HTTP JVM: at org.openntf.domino.impl.ViewEntryCollection.iterator(ViewEntryCollection.java:111)
2023-05-26 09:44:29 HTTP JVM: at org.acme.kkom.dao.AttachmentDominoDAO.updateAccess(AttachmentDominoDAO.java:510)
510 refers to the for loop statement (for (ViewEntry entry : entries) ) in:
View vw = db.getView(propDataSources.getProperty("vw_attach_unid"));
if (null != vw){
ViewEntryCollection entries = vw.createViewEntryCollection();
if (null != key){
entries = vw.getAllEntriesByKey(key, true);
}
else{
entries = vw.getAllEntries();
}
//ODA way:
for (ViewEntry entry : entries) {
if(entry.isValid()){
if(entry.isDocument()){
Document doc = entry.getDocument();
if(null != item){
doc.copyItem(item);
} else{
doc.removeItem(fieldName);
}
if(doc.save(true,false)){
vw.refresh();
}
}
}
}
}
The text was updated successfully, but these errors were encountered: