[ https://issues.apache.org/jira/browse/JEXL-302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16856126#comment-16856126 ]
Henri Biestro commented on JEXL-302: ------------------------------------ I'm sorry, I must have been unclear; let me try again. The intended purpose of getVariable is to retrieve the list of variables susceptible to change the outcome of a script/expression evaluation. The output is a set of list of strings. Each list is at least a (top level) variable followed by properties; if one of this list is {{\{"a", "b"\}}}, it means if there is a solvable variable {{'a'}} - and more precisely a solvable property {{"b"}} of a variable {{"a"}}, varying its value is susceptible to change the outcome of the script evaluation. If one list is {{\{"a", "b", "c"\}}}, it means the solvable property {{"c"}} of the solvable property {{"b"}} of the solvable variable {{"a"}} may have an effect etc. You get the idea. It also means in that latest form case, that {{a['b']['c']}} may behave the same way and thus generates the same list.. A side effect is that the method also picks up the (evil) antish-variables but I suspect (and hope) anyone using those in their environment knows them and should have no difficulty reconciling the output of getVariables and the potential antish vars. As for you example, {{a[b]['c']}} is not equivalent to {{a[b.c]}} ; the latter is equivalent to {{a[b['c']]}}. I've added 2 more examples in VarTest.testRefs ( https://github.com/apache/commons-jexl/commit/66d5f6e69992a6473c94bff2cf17889a428ab622 ). All that being said, I think the feature still works as intended (per JEXL-113). But I hear you, things have changed wrt to property/array resolution so we may want to add an option to that feature to only consider dotted identifiers - not their array counterparts. That's fairly easy (Engine.java, lline 588, add a condition), we just need to specify how to pass it down. I prototried with a boolean argument to getVariable, that works but changes lots of code, adding overloads; may be the Engine could be configured through an option since it is probably related to resolver strategies. Share your thoughts. > JexlScript.getVariables returns strange values for array access > --------------------------------------------------------------- > > Key: JEXL-302 > URL: https://issues.apache.org/jira/browse/JEXL-302 > Project: Commons JEXL > Issue Type: Bug > Affects Versions: 3.1 > Reporter: Dmitri Blinov > Assignee: Henri Biestro > Priority: Minor > Fix For: 3.2 > > > I can not understand the logic behind the current implementation of > {{JexlScript.getVariables()}} method. From the documentation we know that the > result should be the set of script variables. For the code > {code:java} > a[b][c]{code} > it gives three variables {{a}}, {{b}}, {{c}}. So far so good. But for the code > {code:java} > a[b]['c']{code} > it returns {{a}} and {{b c}}, where second variable has two fragments {{b}} > and {{c}}. The documentation states that variables with multiple fragments > are ant-ish variables, but I don't have any of ant-ish variables in the > example, and {{'c'}} is not a variable, but a constant. I expect to get {{a}} > and {{b}} as a result. -- This message was sent by Atlassian JIRA (v7.6.3#76005)