Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-104

NPE in JexlArithmetic when an Array-Expression containing a null is used.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.1
    • 2.1
    • None

    Description

      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.

      Attachments

        1. JexlArithmeticBug.java
          0.4 kB
          Andreas Haufler
        2. FixedJexlArithmetic.java
          2 kB
          Andreas Haufler

        Activity

          People

            henrib Henri Biestro
            aha@scireum.de Andreas Haufler
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: