You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (Jira)" <ji...@apache.org> on 2022/11/04 16:19:00 UTC
[jira] [Resolved] (JEXL-383) Inconsistent behavior after overriding toBoolean method in JexlArithmetic
[ https://issues.apache.org/jira/browse/JEXL-383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Biestro resolved JEXL-383.
--------------------------------
Fix Version/s: 3.3
Resolution: Fixed
Thank you for your issue.
This has been implement through JEXL-359 and is actually being refined in JEXL-384.
Added your test case in the [JEXL-384 branch|https://github.com/apache/commons-jexl/tree/JEXL-384].
> 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)