Dmitri Blinov created JEXL-301:
----------------------------------
Summary: Array access operator does not fail on null object in
non-strict arithmetic mode
Key: JEXL-301
URL: https://issues.apache.org/jira/browse/JEXL-301
Project: Commons JEXL
Issue Type: Bug
Affects Versions: 3.1
Reporter: Dmitri Blinov
Consider the following test cases
{code}
@Test
public void testNullArrayAccess() throws Exception {
JexlEngine jexl = new JexlBuilder().arithmetic(new
JexlArithmetic(false)).create();
JexlScript s = jexl.createScript("var x = null; x[0]");
try {
Object o = s.execute(null);
Assert.fail("Should have failed");
} catch (Exception ex) {
//
}
}
{code} and {code}
@Test
public void testNullArrayAccess2() throws Exception {
JexlEngine jexl = new JexlBuilder().arithmetic(new
JexlArithmetic(false)).create();
JexlScript s = jexl.createScript("var x = [null,1]; x[0][0]");
try {
Object o = s.execute(null);
Assert.fail("Should have failed");
} catch (Exception ex) {
//
}
}
{code}
I exect array access operator to work identically in both cases, i.e. we should
fail on trying to get an array element of null. Nevertheless, only the second
case fails. I think this is a bug.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)