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

Inconsistent behavior after overriding toBoolean method in JexlArithmetic

    XMLWordPrintableJSON

Details

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

    Description

      I tried to overriding "toBoolean" method of JexlArithmetic for 'strict' mode.

      @Override
      public boolean toBoolean(final Object val) {
        if (val == null) {
          return false;
        } else {
          return super.toBoolean(val);
        }
      } 

       while executing code:

      parameters:

      a: null
      

      but while executing scripts, the behavior is inconsistent

      if (a) return 1 else return 2;  // returns 2
      if (!a) return 1 else return 2; // expects return 1 but throws exception: variable 'a' is null

       

      what should I do to fix it? thanks!

      -Pengcheng

       

       

      Attachments

        Activity

          People

            henrib Henri Biestro
            xupengcheng Xu Pengcheng
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: