[
https://issues.apache.org/jira/browse/JCR-3713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13866260#comment-13866260
]
Alexander Klimetschek commented on JCR-3713:
--------------------------------------------
The fix should be simple: if "conditions" is empty, simply add the expression
directly and ignore optional (OR).
> NPE in GQL if it starts with OR expression
> ------------------------------------------
>
> Key: JCR-3713
> URL: https://issues.apache.org/jira/browse/JCR-3713
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Components: jackrabbit-jcr-commons
> Affects Versions: 2.7.3
> Reporter: Alexander Klimetschek
>
> These GQL queries lead to an NPE:
> OR property:something
> path:/content OR property:something
> This is because GQL#pushExpression() will blindly replace the previous entry
> in the "conditions" list, even if it is still empty.
> {code}
> Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
> at java.util.ArrayList.get(ArrayList.java:324)
> at org.apache.jackrabbit.commons.query.GQL.pushExpression(GQL.java:798)
> at org.apache.jackrabbit.commons.query.GQL.access$000(GQL.java:133)
> at org.apache.jackrabbit.commons.query.GQL$1.term(GQL.java:426)
> at org.apache.jackrabbit.commons.query.GQL.parse(GQL.java:682)
> at
> org.apache.jackrabbit.commons.query.GQL.translateStatement(GQL.java:423)
> at org.apache.jackrabbit.commons.query.GQL.execute(GQL.java:389)
> at org.apache.jackrabbit.commons.query.GQL.execute(GQL.java:322)
> {code}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)