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 2021/06/07 13:15:06 UTC

[jira] [Closed] (JEXL-301) Array access operator does not fail on null object in non-strict arithmetic mode

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

Henri Biestro closed JEXL-301.
------------------------------

> 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
>            Assignee: Henri Biestro
>            Priority: Major
>             Fix For: 3.2
>
>
> 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
(v8.3.4#803005)