[jira] Created: (JEXL-104) NPE in JexlArithmetic when an Array-Expression containing a null is used.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (JEXL-104) NPE in JexlArithmetic when an Array-Expression containing a null is used.

JIRA jira@apache.org
NPE in JexlArithmetic when an Array-Expression containing a null is used.
-------------------------------------------------------------------------

                 Key: JEXL-104
                 URL: https://issues.apache.org/jira/browse/JEXL-104
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 2.0.1
            Reporter: Andreas Haufler


When using the Array-Expression like [x, y, z] a NPE occurs when one of the array elements is null.

Example:

import org.apache.commons.jexl2.Expression;
import org.apache.commons.jexl2.JexlEngine;
import org.apache.commons.jexl2.MapContext;

public class JexlArithmeticBug {
        public static void main(String[] args) {
                JexlEngine engine = new JexlEngine();
                String jexlExp = "[null, null]";
                Expression e = engine.createExpression(jexlExp);
                System.out.println(e.evaluate(new MapContext()));
        }
}

As one can see in the Stacktrace, JexlArithmetic.narrowArrayType doesn't expect null values at all.


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (JEXL-104) NPE in JexlArithmetic when an Array-Expression containing a null is used.

JIRA jira@apache.org

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

Andreas Haufler updated JEXL-104:
---------------------------------

    Attachment: JexlArithmeticBug.java
                FixedJexlArithmetic.java

First file shows the bug. The second file is a suggested fix, BUT it is just a give re-write of the original code. I'm not too deep into reflection with arrays and all that so the original author might want to take a look at it and might apply a better fix.

> NPE in JexlArithmetic when an Array-Expression containing a null is used.
> -------------------------------------------------------------------------
>
>                 Key: JEXL-104
>                 URL: https://issues.apache.org/jira/browse/JEXL-104
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 2.0.1
>            Reporter: Andreas Haufler
>         Attachments: FixedJexlArithmetic.java, JexlArithmeticBug.java
>
>
> When using the Array-Expression like [x, y, z] a NPE occurs when one of the array elements is null.
> Example:
> import org.apache.commons.jexl2.Expression;
> import org.apache.commons.jexl2.JexlEngine;
> import org.apache.commons.jexl2.MapContext;
> public class JexlArithmeticBug {
> public static void main(String[] args) {
> JexlEngine engine = new JexlEngine();
> String jexlExp = "[null, null]";
> Expression e = engine.createExpression(jexlExp);
> System.out.println(e.evaluate(new MapContext()));
> }
> }
> As one can see in the Stacktrace, JexlArithmetic.narrowArrayType doesn't expect null values at all.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Issue Comment Edited: (JEXL-104) NPE in JexlArithmetic when an Array-Expression containing a null is used.

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/JEXL-104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12897201#action_12897201 ]

Andreas Haufler edited comment on JEXL-104 at 8/11/10 6:08 AM:
---------------------------------------------------------------

The first file (JexlArithmeticBug.java) shows the bug. The second file (FixedJexlArithmetic.java) is a suggested fix, BUT it is just a give re-write of the original code. I'm not too deep into reflection with arrays and all that so the original author might want to take a look at it and might apply a better fix.

      was (Author: [hidden email]):
    First file shows the bug. The second file is a suggested fix, BUT it is just a give re-write of the original code. I'm not too deep into reflection with arrays and all that so the original author might want to take a look at it and might apply a better fix.
 

> NPE in JexlArithmetic when an Array-Expression containing a null is used.
> -------------------------------------------------------------------------
>
>                 Key: JEXL-104
>                 URL: https://issues.apache.org/jira/browse/JEXL-104
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 2.0.1
>            Reporter: Andreas Haufler
>         Attachments: FixedJexlArithmetic.java, JexlArithmeticBug.java
>
>
> When using the Array-Expression like [x, y, z] a NPE occurs when one of the array elements is null.
> Example:
> import org.apache.commons.jexl2.Expression;
> import org.apache.commons.jexl2.JexlEngine;
> import org.apache.commons.jexl2.MapContext;
> public class JexlArithmeticBug {
> public static void main(String[] args) {
> JexlEngine engine = new JexlEngine();
> String jexlExp = "[null, null]";
> Expression e = engine.createExpression(jexlExp);
> System.out.println(e.evaluate(new MapContext()));
> }
> }
> As one can see in the Stacktrace, JexlArithmetic.narrowArrayType doesn't expect null values at all.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (JEXL-104) NPE in JexlArithmetic when an Array-Expression containing a null is used.

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

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

Henri Biestro resolved JEXL-104.
--------------------------------

    Fix Version/s: 2.0.2
       Resolution: Fixed

Thanks Andreas for catching this one and submitting a fix.

src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
src/test/java/org/apache/commons/jexl2/ArrayLiteralTest.java
Committed revision 984516.

> NPE in JexlArithmetic when an Array-Expression containing a null is used.
> -------------------------------------------------------------------------
>
>                 Key: JEXL-104
>                 URL: https://issues.apache.org/jira/browse/JEXL-104
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 2.0.1
>            Reporter: Andreas Haufler
>            Assignee: Henri Biestro
>             Fix For: 2.0.2
>
>         Attachments: FixedJexlArithmetic.java, JexlArithmeticBug.java
>
>
> When using the Array-Expression like [x, y, z] a NPE occurs when one of the array elements is null.
> Example:
> import org.apache.commons.jexl2.Expression;
> import org.apache.commons.jexl2.JexlEngine;
> import org.apache.commons.jexl2.MapContext;
> public class JexlArithmeticBug {
> public static void main(String[] args) {
> JexlEngine engine = new JexlEngine();
> String jexlExp = "[null, null]";
> Expression e = engine.createExpression(jexlExp);
> System.out.println(e.evaluate(new MapContext()));
> }
> }
> As one can see in the Stacktrace, JexlArithmetic.narrowArrayType doesn't expect null values at all.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.