NullPointerException in XQJ
Hi,
before I prepare a self-contained test case, perhaps this description already rings a bell:
I'm getting with the latest 6.2.2 this NPE:
java.lang.NullPointerException at org.basex.query.up.primitives.UpdatePrimitive.addNode(UpdatePrimitive.java:193) at org.basex.query.up.primitives.UpdatePrimitive.addNode(UpdatePrimitive.java:214) at org.basex.query.up.primitives.UpdatePrimitive.buildDB(UpdatePrimitive.java:133) at org.basex.query.up.primitives.NodeCopy.prepare(NodeCopy.java:47) at org.basex.query.up.Primitives.check(Primitives.java:67) at org.basex.query.up.DBPrimitives.check(DBPrimitives.java:45) at org.basex.query.up.Updates.apply(Updates.java:102) at org.basex.query.QueryContext.iter(QueryContext.java:299) at org.basex.api.xqj.BXQDynamicContext.execute(BXQDynamicContext.java:266) at org.basex.api.xqj.BXQPreparedExpression.executeQuery(BXQPreparedExpression.java:55)
This happens when I pass an actual DOM node to bindNode as argument 2. The error does not occur, and the query runs successfully, when I instead pass the node's ownerDocument. The node is the root of its document.
Actual code:
Works: xqp.bindNode(new QName("entry"), elem.getOwnerDocument(), null);
Fails: xqp.bindNode(new QName("entry"), elem, null);
Here, 'elem' is the root node of a document created via parseXml <http://top.cs.vt.edu/~gback/bx/b622/Test.java>from a string. It uses the JDK's DOM implementation.
I note that in the second bug<http://top.cs.vt.edu/~gback/bx/b622/Test.java>we're discussing, BaseX also shows different behavior for nodes that are the root nodes of their respective documents when passed to bindNode. Which makes me wonder what the correct behavior is. It seems to me that passing a document or its root node to bindNode should result in the same behavior; correct?
Thanks.
- Godmar
Godmar,
thanks for reporting bugs in more detail. I'll be off for a few days; please check out the latest version, in which the issues might have been fixed.
http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex-api/6.2.3/basex-api-6.2.3.jar http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex/6.2.3/basex-6.2.3.jar
Christian
Quoted text · Godmar Back · 54 lines
On Tue, Jul 27, 2010 at 12:25 AM, Godmar Back <godmar at gmail.com> wrote: > > Hi, > > before I prepare a self-contained test case, perhaps this description > already rings a bell: > > I'm getting with the latest 6.2.2 this NPE: > > java.lang.NullPointerException > at > org.basex.query.up.primitives.UpdatePrimitive.addNode(UpdatePrimitive.java:193) > at > org.basex.query.up.primitives.UpdatePrimitive.addNode(UpdatePrimitive.java:214) > at > org.basex.query.up.primitives.UpdatePrimitive.buildDB(UpdatePrimitive.java:133) > at org.basex.query.up.primitives.NodeCopy.prepare(NodeCopy.java:47) > at org.basex.query.up.Primitives.check(Primitives.java:67) > at org.basex.query.up.DBPrimitives.check(DBPrimitives.java:45) > at org.basex.query.up.Updates.apply(Updates.java:102) > at org.basex.query.QueryContext.iter(QueryContext.java:299) > at > org.basex.api.xqj.BXQDynamicContext.execute(BXQDynamicContext.java:266) > at > org.basex.api.xqj.BXQPreparedExpression.executeQuery(BXQPreparedExpression.java:55) > > This happens when I pass an actual DOM node to bindNode as argument 2. > The error does not occur, and the query runs successfully, when I instead > pass the node's ownerDocument. The node is the root of its document. > > Actual code: > > Works: > xqp.bindNode(new QName("entry"), elem.getOwnerDocument(), null); > > Fails: > xqp.bindNode(new QName("entry"), elem, null); > > Here, 'elem' is the root node of a document created via parseXml from a > string. It uses the JDK's DOM implementation. > I note that in the second bug we're discussing, BaseX also shows different > behavior for nodes that are the root nodes of their respective documents > when passed to bindNode. Which makes me wonder what the correct behavior is. > It seems to me that passing a document or its root node to bindNode should > result in the same behavior; correct? > Thanks. > - Godmar > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
Excellent. - This version fixes both bugs (bogus namespace prefixes as well as the NPE when a root node is passed to bindNode.)
Thanks!
- Godmar
Quoted text · Christian Grün · 70 lines
On Tue, Jul 27, 2010 at 10:19 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Godmar, > > thanks for reporting bugs in more detail. I'll be off for a few days; > please check out the latest version, in which the issues might have > been fixed. > > http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex-api/6.2.3/basex-api-6.2.3.jar > http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex/6.2.3/basex-6.2.3.jar > > Christian > ___________________________ > > > On Tue, Jul 27, 2010 at 12:25 AM, Godmar Back <godmar at gmail.com> wrote: >> >> Hi, >> >> before I prepare a self-contained test case, perhaps this description >> already rings a bell: >> >> I'm getting with the latest 6.2.2 this NPE: >> >> java.lang.NullPointerException >> at >> org.basex.query.up.primitives.UpdatePrimitive.addNode(UpdatePrimitive.java:193) >> at >> org.basex.query.up.primitives.UpdatePrimitive.addNode(UpdatePrimitive.java:214) >> at >> org.basex.query.up.primitives.UpdatePrimitive.buildDB(UpdatePrimitive.java:133) >> at org.basex.query.up.primitives.NodeCopy.prepare(NodeCopy.java:47) >> at org.basex.query.up.Primitives.check(Primitives.java:67) >> at org.basex.query.up.DBPrimitives.check(DBPrimitives.java:45) >> at org.basex.query.up.Updates.apply(Updates.java:102) >> at org.basex.query.QueryContext.iter(QueryContext.java:299) >> at >> org.basex.api.xqj.BXQDynamicContext.execute(BXQDynamicContext.java:266) >> at >> org.basex.api.xqj.BXQPreparedExpression.executeQuery(BXQPreparedExpression.java:55) >> >> This happens when I pass an actual DOM node to bindNode as argument 2. >> The error does not occur, and the query runs successfully, when I instead >> pass the node's ownerDocument. The node is the root of its document. >> >> Actual code: >> >> Works: >> xqp.bindNode(new QName("entry"), elem.getOwnerDocument(), null); >> >> Fails: >> xqp.bindNode(new QName("entry"), elem, null); >> >> Here, 'elem' is the root node of a document created via parseXml from a >> string. It uses the JDK's DOM implementation. >> I note that in the second bug we're discussing, BaseX also shows different >> behavior for nodes that are the root nodes of their respective documents >> when passed to bindNode. Which makes me wonder what the correct behavior is. >> It seems to me that passing a document or its root node to bindNode should >> result in the same behavior; correct? >> Thanks. >> - Godmar >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >> >
Written for BaseX 6. BaseX may have changed since: please check the current documentation.