You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (JIRA)" <ji...@apache.org> on 2016/08/31 10:26:20 UTC

[jira] [Resolved] (JEXL-217) Interpreter.getAttribute() raises exception in non-strict mode when cached property resolver is used

     [ https://issues.apache.org/jira/browse/JEXL-217?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Biestro resolved JEXL-217.
--------------------------------
    Resolution: Fixed
      Assignee: Henri Biestro

Cached and non-cached calls are now protected by the same try/catch block.

src/main/java/org/apache/commons/jexl3/internal/Interpreter.java
src/main/java/org/apache/commons/jexl3/internal/Operators.java
src/test/java/org/apache/commons/jexl3/IssuesTest.java

Committed revision 1758541.

> Interpreter.getAttribute() raises exception in non-strict mode when cached property resolver is used
> ----------------------------------------------------------------------------------------------------
>
>                 Key: JEXL-217
>                 URL: https://issues.apache.org/jira/browse/JEXL-217
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>            Assignee: Henri Biestro
>
> I'm chasing strange bug where regardless of the {{JexlContext}} operating in non-strict mode the {{ArrayIndexOutOfBoundsException}} is thrown in the script like this
> {code}
> entity = args[0]; @lenient {copy = args[1]; xwsp = args[2]}
> {code}
> here is the stack trace
> {quote}
> Caused by: java.lang.ArrayIndexOutOfBoundsException
> 	at java.lang.reflect.Array.get(Native Method)
> 	at org.apache.commons.jexl3.internal.introspection.ListGetExecutor.tryInvoke(ListGetExecutor.java:88) 
> 	at org.apache.commons.jexl3.internal.Interpreter.getAttribute(Interpreter.java:1700) 
> 	at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:945) 
> 	at org.apache.commons.jexl3.parser.ASTArrayAccess.jjtAccept(ASTArrayAccess.java:18) 
> 	at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1013) 
> 	at org.apache.commons.jexl3.parser.ASTReference.jjtAccept(ASTReference.java:18) 
> 	at org.apache.commons.jexl3.internal.Interpreter.executeAssign(Interpreter.java:1119) 
> 	at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:1062) 
> 	at org.apache.commons.jexl3.parser.ASTAssignment.jjtAccept(ASTAssignment.java:18) 
> 	at org.apache.commons.jexl3.internal.Interpreter.visit(Interpreter.java:578) 
> 	at org.apache.commons.jexl3.parser.ASTBlock.jjtAccept(ASTBlock.java:18) 
> 	at org.apache.commons.jexl3.internal.Interpreter.processAnnotation(Interpreter.java:1848) 
> 	at org.apache.commons.jexl3.internal.Interpreter$1.call(Interpreter.java:1856) 
> {quote}
> Unfortunately I haven't managed to create and provide reproducible test case, but from looking into the code I think the problem fires when the Interpreter tries to call cached method {{ListGetExecutor.tryInvoke()}} but does not catch subsequent exception.  
> I rewrote the code as follows and the problem seemed to go away
> {code:title=Interpreter.java}
>         ...
>         Exception xcause = null;
>         // attempt to reuse last executor cached in volatile JexlNode.value
>         if (node != null && cache) {
>             Object cached = node.jjtGetValue();
>             if (cached instanceof JexlPropertyGet) {
>                 JexlPropertyGet vg = (JexlPropertyGet) cached;
>                 try {
>                    Object value = vg.tryInvoke(object, attribute);
>                    if (!vg.tryFailed(value)) {
>                        return value;
>                    }
>                 } catch (Exception xany) {
>                     xcause = xany;
>                 }
>             }
>         }
>         if (xcause == null) {
>            // resolve that property
>            List<PropertyResolver> resolvers = uberspect.getResolvers(operator, object);
>            JexlPropertyGet vg = uberspect.getPropertyGet(resolvers, object, attribute);
>            if (vg != null) {
>                try {
>                    Object value = vg.invoke(object);
>                    // cache executor in volatile JexlNode.value
>                    if (node != null && cache && vg.isCacheable()) {
>                        node.jjtSetValue(vg);
>                    }
>                    return value;
>                } catch (Exception xany) {
>                    xcause = xany;
>                }
>            }
>         }
>         ...
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)