Claus Ibsen created CAMEL-24966:
-----------------------------------
Summary: simple - operator and numeric literal fixes
Key: CAMEL-24966
URL: https://issues.apache.org/jira/browse/CAMEL-24966
Project: Camel
Issue Type: Sub-task
Components: camel-core
Reporter: Claus Ibsen
Assignee: Claus Ibsen
Fix For: 4.23.0
Bugs in NumericExpression, OtherExpression, UnaryExpression and
BinaryExpression.
* (verified) {{${body > 0 ? 1 : 0}}} evaluated as Long.class (or int.class)
throws ClassCastException "Cannot cast java.lang.Integer to java.lang.Long".
NumericExpression uses type.cast(number) for Long/Double/int; only shortcut
when type.isInstance(number), otherwise convert.
* (verified) {{${header.x} > -3000000000}} fails with NumberFormatException:
the Integer range check has no lower bound (and 2147483647 becomes a Long, off
by one).
* (verified) Elvis only treats Integer 0 as falsy: header count=0L,
{{${header.count} ?: 'none'}} returns 0. Same for 0.0 and BigDecimal.ZERO. The
left side is also evaluated twice (side-effecting beans run twice).
* (verified) {{${header.price}++}} with 1.5 gives 2.0 (longValue()+1). Same for
--. The left side is evaluated twice. createIncExpression/createDecExpression
are duplicates.
* (verified) Null right-hand side gives raw NPE: {{${body} range ${header.r}}}
and {{${body} regex ${header.p}}} with the header missing.
* SimpleOperatorConstants (not null/empty) and the adoc (effective Boolean)
describe elvis differently; align them.
_Claude Code on behalf of davsclaus (found by an AI review of the simple
language source; each item marked (verified) was reproduced on main at
c3ef718de2e8)_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)