Bug #2713
closedNPE from XQuery when catching collection URI resolver exception
100%
Description
A test of ours contained some code that used fn:collection with a relative URI inside of try-catch. This now results in a NullPointerException.
I understand that a relative URI now requires a base URI to be set, but apparently the corresponding error message fails to pass through catch processing.
This can be reproduced from command line by
java net.sf.saxon.Query -qs:"try {collection('x/y?select=z.xml')} catch err:FODC0002 {'caught'}"
java.lang.NullPointerException
at net.sf.saxon.pattern.NameTest.matches(NameTest.java:207)
at net.sf.saxon.expr.TryCatch.iterate(TryCatch.java:255)
at net.sf.saxon.expr.Expression.process(Expression.java:887)
at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:408)
at net.sf.saxon.s9api.XQueryEvaluator.run(XQueryEvaluator.java:370)
at net.sf.saxon.Query.runQuery(Query.java:900)
at net.sf.saxon.Query.doQuery(Query.java:442)
at net.sf.saxon.Query.main(Query.java:111)
Files
Updated by Gunther Rademacher over 8 years ago
- File NPEfromCatch.java NPEfromCatch.java added
Some further testing showed that I am getting the same exception and stack when throwing an XPathException from a CollectionFinder, e.g.
configuration.setCollectionFinder(new CollectionFinder() {
@Override
public ResourceCollection findCollection(XPathContext paramXPathContext, String paramString) throws XPathException {
throw new XPathException("Class " + getClass().getName() + " refused to find collection " + paramString);
}
});
The test program is attached. Now working around by throwing a RuntimeException.
Updated by Gunther Rademacher over 8 years ago
...but did not realize until now that this is a Saxon XPathExcetion. Using its setErrorCode method helps as well.
Updated by O'Neil Delpratt over 8 years ago
- Category set to XPath conformance
- Status changed from New to Resolved
- Assignee set to O'Neil Delpratt
- Priority changed from Low to Normal
- % Done changed from 0 to 100
- Fix Committed on Branch 9.7 added
Thanks for reporting the problem you found. The exception thrown did not have a error set upon creation, which is a bug. I have added the correct error code 'FODC0002' as expected.
Bug fixed and committed to subversion on the 9.7 and the development branch.
Updated by O'Neil Delpratt over 8 years ago
In addition to the above fix we have taken the step to check if the code is null, which if it is we then assign it a default saxon error code. This precaution was added in the TryCatch class.
Updated by O'Neil Delpratt over 8 years ago
- Status changed from Resolved to Closed
- Fixed in Maintenance Release 9.7.0.5 added
Bug fix applied in the Saxon 9.7.0.5 maintenance release.
Please register to edit this issue