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

Cannot check if variable is defined using ObjectContext if the value is null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2.1
    • 3.3
    • None

    Description

      I'm migrating from 3.1 to 3.2.1, and I've noticed the following change in behaviour when using ObjectContext:

      • Calling ObjectContext.has(String) for an object which has the given property, but for which the current value is null, returns false, and not true as it did before.
      • Similarly, evaluating an expression which uses a property that is defined but which is null, throws an ('is undefined') exception rather than returning the null value.

      The javadoc for JexlContext.has(String) says:

      A variable may be defined with a null value; this method checks whether the value is null or if the variable is undefined.

      so my impression is that the behaviour of ObjectContext does not match what is written in the Javadoc for the JexlContext interface. It is a problem in my case because the 'undefined' exception causes quite a lot of confusion in use.

      I've attached a test class to demonstrate the example. Please let me know if any extra info is needed, and thanks for all the great work on Jexl!

      Attachments

        1. ObjectContextTest.java
          2 kB
          Alex Hutton

        Activity

          People

            henrib Henri Biestro
            ahutton Alex Hutton
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: