NullPointerException with literal FilterExpression
If a filter expression after optimization reduces to something like (1 to 20), where both operands are literals and the index is out of range for the length of the sequence, a NullPointerException occurs rather than returning the empty sequence.
Problem code is at line 1121 in FilterExpression.iterate()
return ((Literal)base).getValue().itemAt(pos - 1).iterate();
where itemAt() can return null.
There is also another instance a few lines earlier where the base expression is a variable reference.
#2 Updated by Michael Kay almost 5 years ago
Reproduced, and fix tested, using the above query with -opt:0. The problem probably occurs only if optimisation is disabled. Also as far as I can see the problem does not occur on the bytecode path, only when interpreted.
A patch has been committed on the 9.6 branch (in addition to the earlier 9.7 fix).
Please register to edit this issue