[
https://issues.apache.org/jira/browse/JEXL-257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16838409#comment-16838409
]
Henri Biestro edited comment on JEXL-257 at 5/13/19 9:34 AM:
-------------------------------------------------------------
After much debate, the semantic of 'tryInvoke' will be changed and precised.
When a 'Jexl\{Method, Setter, Getter\}' is called through tryInvoke(...), the
invocation will happen if the underlying method signature and actual arguments
are compatible. If the call compatibility can not be ensured, the TRY_FAIL
object is returned. As of 3.2, if the invocation occurs but the underlying
method throws an Exception - which is carried through an
InvocationTargetException - , tryInvoke will throw a JexlException.TryFailed
wrapping the exception cause.
This is a change in behaviour that is not expected to impact user code since
exception occurring through invocation is expected to be very rate and
tryInvoke is likely to only be used internally by JEXL.
was (Author: henrib):
After much debate, the semantic of 'tryInvoke' will be changed and precised.
When a Jexl{Method, Setter, Getter} is called through tryInvoke(...), the
invocation will happen if the underlying method signature and actual arguments
are compatible. If the call compatibility can not be ensured, the TRY_FAIL
object is returned. As of 3.2, if the invocation occurs but the underlying
method throws an Exception - which is carried through an
InvocationTargetException - , tryInvoke will throw a JexlException.TryFailed
wrapping the exception cause.
This is a change in behaviour that is not expected to impact user code since
exception occurring through invocation is expected to be very rate and
tryInvoke is likely to only be used internally by JEXL.
> Function throwing IllegalArgumentException may be called twice
> --------------------------------------------------------------
>
> Key: JEXL-257
> URL: https://issues.apache.org/jira/browse/JEXL-257
> Project: Commons JEXL
> Issue Type: Bug
> Affects Versions: 3.1
> Reporter: Dmitri Blinov
> Priority: Major
>
> 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.
> {code:java}
> eval("java = 1")
> {code}
> Then I have a {{Context.set()}} that works like this
> {code:java}
> public void set(String name) {
> if (name.equals("java"))
> throw new IllegalArgumentException("java");
> ...
> {code}
> 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
> {quote}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]
> {quote}
> and the one for the second
> {quote}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]
> {quote}
> I think this is a bug and we should not call a function twice if it returned
> {{IllegalArgumentException}}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)