Xu Pengcheng created JEXL-383:
---------------------------------

             Summary: Inconsistent behavior after overriding toBoolean method 
in JexlArithmetic
                 Key: JEXL-383
                 URL: https://issues.apache.org/jira/browse/JEXL-383
             Project: Commons JEXL
          Issue Type: Bug
    Affects Versions: 3.2.1
            Reporter: Xu Pengcheng


I tried to overriding "toBoolean" method of JexlArithmetic for 'strict' mode.
{code:java}
@Override
public boolean toBoolean(final Object val) {
  if (val == null) {
    return false;
  } else {
    return super.toBoolean(val);
  }
} {code}
 while executing code:

parameters:
{code:java}
a: null
{code}
but while executing scripts, the behavior is inconsistent
{code:java}
if (a) return 1 else return 2;  // returns 2
if (!a) return 1 else return 2; // expect returns 1 but throws exception: 
variable 'a' is null{code}
 

what should I do to fix it? thanks!

-Pengcheng

 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to