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 2019/05/22 16:32:00 UTC

[jira] [Resolved] (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 resolved JEXL-301.
--------------------------------
    Resolution: Fixed

Thanks for the bug report and unit tests; https://github.com/apache/commons-jexl/commit/68d1b317f38e49a6cad3c283ad05c7d79f29b490

> 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
(v7.6.3#76005)