Using the CVS version of OPS, I'm getting a null pointer when using a
submission with replace="instance". 2006-03-17 09:55:32,723 DEBUG org.orbeon.oxf.xforms.processor.XFormsServer - XForms - submit error exception: java.lang.NullPointerException at org.orbeon.oxf.xforms.XFormsIndexUtils.adjustIndexes(XFormsIndexUtils.java:98) at org.orbeon.oxf.xforms.XFormsModel.handleNewInstanceDocuments(XFormsModel.java:1107) at org.orbeon.oxf.xforms.XFormsModelSubmission.performDefaultAction(XFormsModelSubmission.java:501) at org.orbeon.oxf.xforms.XFormsContainingDocument.dispatchEvent(XFormsContainingDocument.java:618) at org.orbeon.oxf.xforms.action.XFormsActionInterpreter.runAction(XFormsActionInterpreter.java:423) at org.orbeon.oxf.xforms.action.XFormsActionInterpreter.runAction(XFormsActionInterpreter.java:144) at org.orbeon.oxf.xforms.XFormsContainingDocument.runAction(XFormsContainingDocument.java:643) at org.orbeon.oxf.xforms.event.XFormsEventHandlerImpl.handleEvent(XFormsEventHandlerImpl.java:85) at org.orbeon.oxf.xforms.XFormsContainingDocument.dispatchEvent(XFormsContainingDocument.java:604) at org.orbeon.oxf.xforms.XFormsContainingDocument.interpretEvent(XFormsContainingDocument.java:366) at org.orbeon.oxf.xforms.XFormsContainingDocument.executeExternalEvent(XFormsContainingDocument.java:354) at org.orbeon.oxf.xforms.processor.XFormsServer.executeExternalEventPrepareIfNecessary(XFormsServer.java:262) at org.orbeon.oxf.xforms.processor.XFormsServer.doIt(XFormsServer.java:214) Debugging through, it's falling over here: for (Iterator i = currentControlsState.getRepeatIdToIndex().entrySet().iterator(); i.hasNext();) { because the getRepeatIdToIndex() map is null (the form has no repeats so I guess this makes sense). Instinctive fix is to assign the Map to a variable and check for null, but I notice many places where this check is done, like so: final Map repeatIdToIndex = currentControlsState.getRepeatIdToIndex(); if (repeatIdToIndex != null && repeatIdToIndex.size() != 0) { It would be neater to simply return an empty map from XFormsControls$ControlsState rather than null, to avoid all these checks and the risk of NullPointers. eg something like public Map getRepeatIdToIndex() { if (repeatIdToIndex == null) { if(defaultRepeatIdToIndex == null) { return Collections.EMPTY_MAP; } repeatIdToIndex = new HashMap(defaultRepeatIdToIndex); } return repeatIdToIndex; } Adrian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Adrian,
Looks like a good fix! I entered and fixed the bug: http://forge.objectweb.org/tracker/index.php?func=detail&aid=304866&group_id=168&atid=350207 -Erik Adrian Baker wrote: > Using the CVS version of OPS, I'm getting a null pointer when using a > submission with replace="instance". > > 2006-03-17 09:55:32,723 DEBUG > org.orbeon.oxf.xforms.processor.XFormsServer - XForms - submit error > exception: java.lang.NullPointerException > at > org.orbeon.oxf.xforms.XFormsIndexUtils.adjustIndexes(XFormsIndexUtils.java:98) > > at > org.orbeon.oxf.xforms.XFormsModel.handleNewInstanceDocuments(XFormsModel.java:1107) > > at > org.orbeon.oxf.xforms.XFormsModelSubmission.performDefaultAction(XFormsModelSubmission.java:501) > > at > org.orbeon.oxf.xforms.XFormsContainingDocument.dispatchEvent(XFormsContainingDocument.java:618) > > at > org.orbeon.oxf.xforms.action.XFormsActionInterpreter.runAction(XFormsActionInterpreter.java:423) > > at > org.orbeon.oxf.xforms.action.XFormsActionInterpreter.runAction(XFormsActionInterpreter.java:144) > > at > org.orbeon.oxf.xforms.XFormsContainingDocument.runAction(XFormsContainingDocument.java:643) > > at > org.orbeon.oxf.xforms.event.XFormsEventHandlerImpl.handleEvent(XFormsEventHandlerImpl.java:85) > > at > org.orbeon.oxf.xforms.XFormsContainingDocument.dispatchEvent(XFormsContainingDocument.java:604) > > at > org.orbeon.oxf.xforms.XFormsContainingDocument.interpretEvent(XFormsContainingDocument.java:366) > > at > org.orbeon.oxf.xforms.XFormsContainingDocument.executeExternalEvent(XFormsContainingDocument.java:354) > > at > org.orbeon.oxf.xforms.processor.XFormsServer.executeExternalEventPrepareIfNecessary(XFormsServer.java:262) > > at > org.orbeon.oxf.xforms.processor.XFormsServer.doIt(XFormsServer.java:214) > > Debugging through, it's falling over here: > > for (Iterator i = > currentControlsState.getRepeatIdToIndex().entrySet().iterator(); > i.hasNext();) { > > because the getRepeatIdToIndex() map is null (the form has no repeats so > I guess this makes sense). Instinctive fix is to assign the Map to a > variable and check for null, but I notice many places where this check > is done, like so: > > final Map repeatIdToIndex = > currentControlsState.getRepeatIdToIndex(); > if (repeatIdToIndex != null && repeatIdToIndex.size() != 0) { > > > It would be neater to simply return an empty map from > XFormsControls$ControlsState rather than null, to avoid all these > checks and the risk of NullPointers. eg something like > > public Map getRepeatIdToIndex() { > if (repeatIdToIndex == null) { > if(defaultRepeatIdToIndex == null) { > return Collections.EMPTY_MAP; > } > repeatIdToIndex = new HashMap(defaultRepeatIdToIndex); > } > return repeatIdToIndex; > } > > Adrian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |