eiiches / jackson-jq

jq for Jackson Java JSON Processor
Other
281 stars 36 forks source link

Bug in jq parser #18

Closed larsga closed 3 years ago

larsga commented 6 years ago

The following jq queries all fail with the same error:

The stack trace is

java.util.EmptyStackException
    at java.util.Stack.peek(Stack.java:102)
    at java.util.Stack.pop(Stack.java:84)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParserTokenManager.TokenLexicalActions(JsonQueryParserTokenManager.java:1025)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParserTokenManager.getNextToken(JsonQueryParserTokenManager.java:965)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.jj_ntk_f(JsonQueryParser.java:2172)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.PrimaryExpression(JsonQueryParser.java:424)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.BinaryOperatorExpression(JsonQueryParser.java:226)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.TupleExpression(JsonQueryParser.java:199)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.JsonQuery(JsonQueryParser.java:126)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.Start(JsonQueryParser.java:117)
    at net.thisptr.jackson.jq.internal.javacc.JsonQueryParser.compile(JsonQueryParser.java:22)
    at net.thisptr.jackson.jq.JsonQuery.compile(JsonQuery.java:36)
eiiches commented 6 years ago

Thank you for reporting! Exceptions are expected as the queries are not valid. But yes, we should handle these condition properly or at least wrap this EmptyStackException in JsonQueryException. I'll fix this.

eiiches commented 3 years ago

I believe this issue has been resolved. jackson-jq still throws an exception but it's now a JsonQueryException, not EmptyStackException.