Project

Profile

Help

Bug #2594

closed

NullPointerException when compiling an XPath expression

Added by Alin Balasa over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
High
Category:
Internals
Sprint/Milestone:
-
Start date:
2016-01-21
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7
Fixed in Maintenance Release:
Platforms:

Description

I have obtained a NPE when trying to compile the next XPath expression:

ancestor-or-self::*[@conref] | .[ancestor-or-self::p][@conref]
Exception in thread "main" java.lang.NullPointerException: Internal error: expression .[exists(...)][exists(...)] has no retained static context
	at net.sf.saxon.expr.Expression.getConfiguration(Expression.java:1089)
	at net.sf.saxon.expr.FilterExpression.optimize(FilterExpression.java:296)
	at net.sf.saxon.expr.FilterExpression.optimize(FilterExpression.java:457)
	at net.sf.saxon.expr.Operand.optimize(Operand.java:200)
	at net.sf.saxon.expr.Expression.optimizeChildren(Expression.java:496)
	at net.sf.saxon.expr.UnaryExpression.optimize(UnaryExpression.java:112)
	at net.sf.saxon.expr.Operand.optimize(Operand.java:200)
	at net.sf.saxon.expr.sort.DocumentSorter.optimize(DocumentSorter.java:99)
	at net.sf.saxon.expr.Operand.optimize(Operand.java:200)
	at net.sf.saxon.expr.Expression.optimizeChildren(Expression.java:496)
	at net.sf.saxon.expr.BinaryExpression.optimize(BinaryExpression.java:171)
	at net.sf.saxon.expr.VennExpression.optimize(VennExpression.java:312)
	at net.sf.saxon.sxpath.XPathEvaluator.createExpression(XPathEvaluator.java:150)
	at net.sf.saxon.s9api.XPathCompiler.internalCompile(XPathCompiler.java:506)
	at net.sf.saxon.s9api.XPathCompiler.compile(XPathCompiler.java:481)
	at Sample.main(Sample.java:12)

The problem can be reproduced running this code:

public static void main(String[] args) throws Exception {
		net.sf.saxon.s9api.Processor processor = new net.sf.saxon.s9api.Processor(true);
		XPathCompiler newXPathCompiler = processor.newXPathCompiler();
		newXPathCompiler.compile("ancestor-or-self::*[@conref] | .[ancestor-or-self::p][@conref]");
}
Actions #1

Updated by O'Neil Delpratt over 8 years ago

  • Assignee set to O'Neil Delpratt
  • Priority changed from Low to High
  • Found in version deleted (9.7.0.2)
  • Applies to branch 9.7 added
Actions #2

Updated by O'Neil Delpratt over 8 years ago

  • Category set to Internals
  • Status changed from New to Resolved
  • % Done changed from 0 to 100
  • Fix Committed on Branch 9.7 added

Bug fixed and committed to subversion.

Fix was applied in the optimize method of the FilterExpression class. Here we try to optimize the filter so that it does the cheaper one first. However we failed to copy the RetainedStaticContext when swapping.

Actions #3

Updated by O'Neil Delpratt about 8 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.7.0.3 added

Bug fix applied in the Saxon 9.7.0.3 maintenance release.

Please register to edit this issue

Also available in: Atom PDF