Project

Profile

Help

Bug #4721

closed

NullPointerException for calling fn:apply on empty sequence

Added by Martin Honnen over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
-
Start date:
2020-09-04
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, 9.9, trunk
Fix Committed on Branch:
10, 9.9, trunk
Fixed in Maintenance Release:
Platforms:

Description

I noticed that the simple XQuery () => apply([]) gives a NullPointerException in Saxon. Shouldn't it raise XPTY0004?

java -cp 'C:\Program Files\Saxonica\SaxonHE10-2J\saxon-he-10.2.jar' net.sf.saxon.Query -qs:"() => apply([])"
<?xml version="1.0" encoding="UTF-8"?>java.lang.NullPointerException
        at net.sf.saxon.functions.ApplyFn.call(ApplyFn.java:128)
        at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:548)
        at net.sf.saxon.expr.Expression.process(Expression.java:949)
        at net.sf.saxon.expr.SystemFunctionCall.process(SystemFunctionCall.java:481)
        at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:455)
        at net.sf.saxon.s9api.XQueryEvaluator.run(XQueryEvaluator.java:370)
        at net.sf.saxon.Query.runQuery(Query.java:895)
        at net.sf.saxon.Query.doQuery(Query.java:423)
        at net.sf.saxon.Query.main(Query.java:97)
Fatal error during query: java.lang.NullPointerException:  (no message)

It is not particulary meaninful to pass the empty sequence but I guess Saxon doesn't want to acknowledge that with a NullPointerException and furthermore in real code using function-lookup(..) => apply([..]) it is easy to end up with an empty sequence erroneously passed in.

Please register to edit this issue

Also available in: Atom PDF