[jira] [Comment Edited] (JEXL-246) Intermittent ambiguous method invocation when processing assignOverload
[ https://issues.apache.org/jira/browse/JEXL-246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16327643#comment-16327643 ] Henri Biestro edited comment on JEXL-246 at 1/16/18 7:30 PM: - Not all Overloads on side-effects operators are properly detected. Note that the *default* behavior of self assignment is based on the base operator behavior; so 'x += y' is equivalent to 'x = x + y'. If y == null, x + y will provoque an error due to a null operand. 'x += y' will generate an error with the same cause. was (Author: henrib): Overloads on side-effects operators are not always detected > Intermittent ambiguous method invocation when processing assignOverload > --- > > Key: JEXL-246 > URL: https://issues.apache.org/jira/browse/JEXL-246 > Project: Commons JEXL > Issue Type: Bug >Affects Versions: 3.1 >Reporter: Dmitri Blinov >Assignee: Henri Biestro >Priority: Minor > Fix For: 3.2 > > > Sometimes the simple operator like {code}z += 1{code} when {{z}} has not been > defined yet raises an exception > {{org.apache.commons.jexl3.internal.introspection.MethodKey$AmbiguousException}} > with the following stack trace: > {quote} > ambiguous method invocation: MyArithmetic.selfAdd(null, java.lang.Integer) > org.apache.commons.jexl3.internal.introspection.MethodKey$AmbiguousException: > null > at > org.apache.commons.jexl3.internal.introspection.MethodKey$Parameters.getMostSpecific(MethodKey.java:540) > at > org.apache.commons.jexl3.internal.introspection.MethodKey$Parameters.access$000(MethodKey.java:452) > at > org.apache.commons.jexl3.internal.introspection.MethodKey.getMostSpecificMethod(MethodKey.java:261) > at > org.apache.commons.jexl3.internal.introspection.ClassMap.getMethod(ClassMap.java:178) > > at > org.apache.commons.jexl3.internal.introspection.Introspector.getMethod(Introspector.java:146) > at > org.apache.commons.jexl3.internal.introspection.MethodExecutor.discover(MethodExecutor.java:52) > at > org.apache.commons.jexl3.internal.introspection.Uberspect.getMethod(Uberspect.java:218) > > at MyUberspect.getMethod(MyUberspect.java:168) > at > org.apache.commons.jexl3.internal.introspection.Uberspect$ArithmeticUberspect.getOperator(Uberspect.java:413) > at > org.apache.commons.jexl3.internal.Operators.tryOverload(Operators.java:85) > at > org.apache.commons.jexl3.internal.Operators.tryAssignOverload(Operators.java:118) > > at > org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1292) > > at > org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1102) > > {quote} > The class MyArithmetic contains a couple of overloaded > {{public JexlOperator selfAdd(T x, Object y)}} methods with the first > argument being the desired type {{T}} like {{Appendable}} or {{Collection}} > for which the {{+=}} operator is overloaded. > Obviously in case where the first argument is null and the second argument is > an Integer it is not possible to differentiate between {{public JexlOperator > selfAdd(Collection x, Object y)}} and {{public JexlOperator > selfAdd(Appendable x, Object y)}} but I wonder is there any point in trying > to perform {{selfAdd}} on the null variable? What questions me more is that > this error is intermittent and sometimes there is an exception and sometimes > there is not, so at the moment I have no test case to reproduce. So I think > this is a bug. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Comment Edited] (JEXL-246) Intermittent ambiguous method invocation when processing assignOverload
[ https://issues.apache.org/jira/browse/JEXL-246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16324122#comment-16324122 ] Dmitri Blinov edited comment on JEXL-246 at 1/12/18 3:40 PM: - As it has turned out for me, Jexl restricts me, for some reason, from overloading operators in Arithmetic, if the operator signature is of generalized form, like {{operator(Object)}} or {{operator(Object, Object)}}. So the idea of having {{public JexlOperator selfAdd(Object x, Object y)}} does not apply. I don't know if it worth raising an issue about that, or it's better to find the more appropriate solution to the original problem. Lets not over-complicate. Suppose, we have an original script for {{z += 1}} and standard Arithmetic without any {{selfAdd}} overloaded operators. Should this work for an empty z value? I think it should. So, it should work exactly the same as with any number of {{selfAdd}} overloaded operators too. It's not an ambiguity, it's like Jexl couldn't find an appropriate overloaded operator for this case, and reverted to the default implementation. was (Author: dmitri_blinov): As it has turned out for me, Jexl restricts me, for some reason, from overloading operators in Arithmetic, if the operator signature is of generalized form, like {{operator(Object)}} or {{operator(Object, Object)}}. So the idea of having {{public JexlOperator selfAdd(Object x, Object y)}} does not apply. I don't know if it worth raising an issue about that, or it's better to find more appropriate the solution to the original problem. Lets not over-complicate. Suppose, we have an original script for {{z += 1}} and standard Arithmetic without any {{selfAdd}} overloaded operators. Should this work for an empty z value? I think it should. So, it should work exactly the same as with any number of {{selfAdd}} overloaded operators too. It's not an ambiguity, it's like Jexl couldn't find an appropriate overloaded operator for this case, and reverted to the default implementation. > Intermittent ambiguous method invocation when processing assignOverload > --- > > Key: JEXL-246 > URL: https://issues.apache.org/jira/browse/JEXL-246 > Project: Commons JEXL > Issue Type: Bug >Affects Versions: 3.1 >Reporter: Dmitri Blinov >Assignee: Henri Biestro >Priority: Minor > Fix For: 3.2 > > > Sometimes the simple operator like {code}z += 1{code} when {{z}} has not been > defined yet raises an exception > {{org.apache.commons.jexl3.internal.introspection.MethodKey$AmbiguousException}} > with the following stack trace: > {quote} > ambiguous method invocation: MyArithmetic.selfAdd(null, java.lang.Integer) > org.apache.commons.jexl3.internal.introspection.MethodKey$AmbiguousException: > null > at > org.apache.commons.jexl3.internal.introspection.MethodKey$Parameters.getMostSpecific(MethodKey.java:540) > at > org.apache.commons.jexl3.internal.introspection.MethodKey$Parameters.access$000(MethodKey.java:452) > at > org.apache.commons.jexl3.internal.introspection.MethodKey.getMostSpecificMethod(MethodKey.java:261) > at > org.apache.commons.jexl3.internal.introspection.ClassMap.getMethod(ClassMap.java:178) > > at > org.apache.commons.jexl3.internal.introspection.Introspector.getMethod(Introspector.java:146) > at > org.apache.commons.jexl3.internal.introspection.MethodExecutor.discover(MethodExecutor.java:52) > at > org.apache.commons.jexl3.internal.introspection.Uberspect.getMethod(Uberspect.java:218) > > at MyUberspect.getMethod(MyUberspect.java:168) > at > org.apache.commons.jexl3.internal.introspection.Uberspect$ArithmeticUberspect.getOperator(Uberspect.java:413) > at > org.apache.commons.jexl3.internal.Operators.tryOverload(Operators.java:85) > at > org.apache.commons.jexl3.internal.Operators.tryAssignOverload(Operators.java:118) > > at > org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1292) > > at > org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1102) > > {quote} > The class MyArithmetic contains a couple of overloaded > {{public JexlOperator selfAdd(T x, Object y)}} methods with the first > argument being the desired type {{T}} like {{Appendable}} or {{Collection}} > for which the {{+=}} operator is overloaded. > Obviously in case where the first argument is null and the second argument is > an Integer it is not possible to differentiate between {{public JexlOperator > selfAdd(Collection x, Object y)}} and {{public JexlOperator > selfAdd(Appendable x, Object y)}} but I wonder is there any point in trying > to perform {{selfAdd}} on the null variable? What questions me more is that > this error is
[jira] [Comment Edited] (JEXL-246) Intermittent ambiguous method invocation when processing assignOverload
[ https://issues.apache.org/jira/browse/JEXL-246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16316464#comment-16316464 ] Henri Biestro edited comment on JEXL-246 at 1/8/18 3:17 PM: The behavior is not intermittent; when JEXL detects an ambiguity when resolving a method, it will log this exception as an info (using the JEXL engine logger if configured to allow these) and will remember this signature as a cache-miss. The second time this resolution is attempted, the cache-miss will be detected to return a null (and avoid throwing the same exception twice). In effect, the MethodKey.AmbiguousException will only be logged once (per lifetime of the Introspector). The fix makes it clearer to determine what the error is due to; in the accompanying case, it is due to a null operand (z) during operator evaluation. trunk/RELEASE-NOTES.txt trunk/src/main/java/org/apache/commons/jexl3/internal/Operators.java trunk/src/site/xdoc/changes.xml trunk/src/test/java/org/apache/commons/jexl3/IssuesTest200.java Committed revision 1820568. was (Author: henrib): The behavior is not intermittent; when JEXL detects an ambiguity when resolving a method, it will log this exception as an info (using the JEXL engine logger if configured to allow these) and will remember this signature as a cache-miss. The second time this resolution is attempted, the cache-miss will be detected to return a null (and avoid throwing the same exception twice). In effect, the MethodKey.AmbiguousException will only be logged once (per lifetime of the Introspector). The fix though is to make it clearer what the error is due to; in the accompanying case, it is due to a null operand (z) during operator evaluation. trunk/RELEASE-NOTES.txt trunk/src/main/java/org/apache/commons/jexl3/internal/Operators.java trunk/src/site/xdoc/changes.xml trunk/src/test/java/org/apache/commons/jexl3/IssuesTest200.java Committed revision 1820568. > Intermittent ambiguous method invocation when processing assignOverload > --- > > Key: JEXL-246 > URL: https://issues.apache.org/jira/browse/JEXL-246 > Project: Commons JEXL > Issue Type: Bug >Affects Versions: 3.1 >Reporter: Dmitri Blinov >Assignee: Henri Biestro >Priority: Minor > Fix For: 3.2 > > > Sometimes the simple operator like {code}z += 1{code} when {{z}} has not been > defined yet raises an exception > {{org.apache.commons.jexl3.internal.introspection.MethodKey$AmbiguousException}} > with the following stack trace: > {quote} > ambiguous method invocation: MyArithmetic.selfAdd(null, java.lang.Integer) > org.apache.commons.jexl3.internal.introspection.MethodKey$AmbiguousException: > null > at > org.apache.commons.jexl3.internal.introspection.MethodKey$Parameters.getMostSpecific(MethodKey.java:540) > at > org.apache.commons.jexl3.internal.introspection.MethodKey$Parameters.access$000(MethodKey.java:452) > at > org.apache.commons.jexl3.internal.introspection.MethodKey.getMostSpecificMethod(MethodKey.java:261) > at > org.apache.commons.jexl3.internal.introspection.ClassMap.getMethod(ClassMap.java:178) > > at > org.apache.commons.jexl3.internal.introspection.Introspector.getMethod(Introspector.java:146) > at > org.apache.commons.jexl3.internal.introspection.MethodExecutor.discover(MethodExecutor.java:52) > at > org.apache.commons.jexl3.internal.introspection.Uberspect.getMethod(Uberspect.java:218) > > at MyUberspect.getMethod(MyUberspect.java:168) > at > org.apache.commons.jexl3.internal.introspection.Uberspect$ArithmeticUberspect.getOperator(Uberspect.java:413) > at > org.apache.commons.jexl3.internal.Operators.tryOverload(Operators.java:85) > at > org.apache.commons.jexl3.internal.Operators.tryAssignOverload(Operators.java:118) > > at > org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1292) > > at > org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1102) > > {quote} > The class MyArithmetic contains a couple of overloaded > {{public JexlOperator selfAdd(T x, Object y)}} methods with the first > argument being the desired type {{T}} like {{Appendable}} or {{Collection}} > for which the {{+=}} operator is overloaded. > Obviously in case where the first argument is null and the second argument is > an Integer it is not possible to differentiate between {{public JexlOperator > selfAdd(Collection x, Object y)}} and {{public JexlOperator > selfAdd(Appendable x, Object y)}} but I wonder is there any point in trying > to perform {{selfAdd}} on the null variable? What questions me more is that > this error is intermittent and sometimes there is an exception and sometimes > there is not, so