Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.1
-
None
Description
Consider the following test cases
@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) { // } }
and
@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) { // } }
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.