Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.1
-
None
Description
With regard to JEXL-256 I have noticed that a function which once had throw IllegalArgumentException may be called immediately once again in script. The problem is not always reproducible so I think it is somehow related to caching and tryInvoke() being called first and invoke() called afterwards.
I can't produce test case at the moment but try to describe on the example. I ommited some irrelevant details for the sake of simplicity...
First I have a function that evaluates Jexl script within script.
eval("java = 1")
Then I have a Context.set() that works like this
public void set(String name) { if (name.equals("java")) throw new IllegalArgumentException("java"); ...
As I stated in JEXL-256, when Context.set() throws IllegalArgumentException then script execution immediately terminates with this exception, and not with JexlException. So, the function eval() im my case terminates with IllegalArgumentException also.
Then I have two stack traces in the log, one for the first invocation
java.lang.IllegalArgumentException: java
at MyDefaultContext.set(MyDefaultContext.java:279)
at org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1189) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1094) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTAssignment.jjtAccept(ASTAssignment.java:18) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:890) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTJexlScript.jjtAccept(ASTJexlScript.java:58) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.interpret(Interpreter.java:190) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Script.execute(Script.java:185) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at EvaluationContext.evalScript(EvaluationContext.java:1078)
at EvaluationContext.evaluateScript(EvaluationContext.java:1043)
at MyDefaultContext.eval(MyDefaultContext.java:736)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_162]
at org.apache.commons.jexl3.internal.introspection.MethodExecutor.invoke(MethodExecutor.java:93) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.introspection.MethodExecutor.tryInvoke(MethodExecutor.java:104) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter$Funcall.tryInvoke(Interpreter.java:1436) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.call(Interpreter.java:1545) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1357) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTFunctionNode.jjtAccept(ASTFunctionNode.java:18) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1149) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1094) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTAssignment.jjtAccept(ASTAssignment.java:18) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.processAnnotation(Interpreter.java:1907) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter$1.call(Interpreter.java:1917) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at com.msy.einie.f1.jexl.MsyDefaultContext.processAnnotation(MsyDefaultContext.java:531) ~[msy-1.0.jar:1.0]
at org.apache.commons.jexl3.internal.Interpreter.processAnnotation(Interpreter.java:1963) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.processAnnotation(Interpreter.java:1936) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1877) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTAnnotatedStatement.jjtAccept(ASTAnnotatedStatement.java:18) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:890) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTJexlScript.jjtAccept(ASTJexlScript.java:58) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.interpret(Interpreter.java:190) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Script.execute(Script.java:185) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
and the one for the second
java.lang.IllegalArgumentException: java
at MyDefaultContext.set(MyDefaultContext.java:279)
at org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1189) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1094) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTAssignment.jjtAccept(ASTAssignment.java:18) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:890) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTJexlScript.jjtAccept(ASTJexlScript.java:58) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.interpret(Interpreter.java:190) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Script.execute(Script.java:185) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at EvaluationContext.evalScript(EvaluationContext.java:1078)
at EvaluationContext.evaluateScript(EvaluationContext.java:1043)
at MyDefaultContext.eval(MyDefaultContext.java:736)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_162]
at org.apache.commons.jexl3.internal.introspection.MethodExecutor.invoke(MethodExecutor.java:93) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.call(Interpreter.java:1642) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1357) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTFunctionNode.jjtAccept(ASTFunctionNode.java:18) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1149) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1094) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTAssignment.jjtAccept(ASTAssignment.java:18) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.processAnnotation(Interpreter.java:1907) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter$1.call(Interpreter.java:1917) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at com.msy.einie.f1.jexl.MsyDefaultContext.processAnnotation(MsyDefaultContext.java:531) ~[msy-1.0.jar:1.0]
at org.apache.commons.jexl3.internal.Interpreter.processAnnotation(Interpreter.java:1963) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.processAnnotation(Interpreter.java:1936) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1877) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTAnnotatedStatement.jjtAccept(ASTAnnotatedStatement.java:18) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:890) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.parser.ASTJexlScript.jjtAccept(ASTJexlScript.java:58) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Interpreter.interpret(Interpreter.java:190) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
at org.apache.commons.jexl3.internal.Script.execute(Script.java:185) ~[commons-jexl-3.2.jar:3.2-SNAPSHOT]
I think this is a bug and we should not call a function twice if it returned IllegalArgumentException