Vincent Bussol created JEXL-434:
-----------------------------------
Summary: The safe-access array operator is not safe
Key: JEXL-434
URL: https://issues.apache.org/jira/browse/JEXL-434
Project: Commons JEXL
Issue Type: Bug
Affects Versions: 3.4.0
Reporter: Vincent Bussol
>From the documentation:
{code:java}
The safe-access array operator (as in foo?[bar]) provides the same behavior as
the safe-access operator and shortcuts any null or non-existent references
along the navigation path, allowing a safe-navigation free of errors. In the
previous expression, if 'foo' is null, the whole expression will evaluate as
null. {code}
Trying to use this syntax:
{code:java}
JexlEngine jexl = new JexlBuilder().safe(false).strict(true).create();
final String src = "let foo = null; let value = foo?[bar]";
final JexlScript script = jexl.createScript(src);
assertNotNull(script);
final Object result = script.execute(null);
assertNull(result); {code}
throws a Variable exception:
{code:java}
1:29 variable 'foo' is null {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)