[
https://issues.apache.org/jira/browse/JEXL-383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Henri Biestro closed JEXL-383.
------------------------------
> 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
> Assignee: Henri Biestro
> Priority: Major
> Fix For: 3.3
>
>
> 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; // expects return 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)