[ 
https://issues.apache.org/jira/browse/CAMEL-24407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110246#comment-18110246
 ] 

Karol Krawczyk commented on CAMEL-24407:
----------------------------------------

Ivan raised a follow-up on the PR 
([comment|https://github.com/apache/camel/pull/25945#issuecomment-5493047248]) 
about digit strings with leading zeros, such as {{"0001"}} vs {{"001"}}. 
Recording the answer here too, since the ticket is already resolved.

That comparison evaluates to {{true}} and the filter matches, both before and 
after this fix. I ran the predicate through a CamelContext on the merged code, 
and the same comparison on 4.8.0 gives an identical result.

It is not a path this fix touches. Camel coerces all-digit strings to numbers 
in {{ObjectHelper.typeCoerceStringPair}}, and both of those values fit in a 
long, so they take the same {{longPairComparison}} they always did. What 
changed here is only the branch for values that do not fit in a long, which 
previously threw {{NumberFormatException}}. Quoting does not opt out of it 
either: {{'${header.Account1}' == '${header.Account2}'}} is also {{true}}.

One consequence worth naming, since it cuts against this fix: for the overflow 
case it reads the other way. {{"0012345678901234567890" == 
"12345678901234567890"}} used to throw and now returns {{true}}, so a loud 
failure became a silent answer for anyone treating those strings as identifiers.

Whether all-digit strings used as identifiers (account numbers, ZIP codes) 
should compare as text rather than as numbers is a real question, but a 
separate one. Changing it would affect every all-digit comparison in 
{{simple}}, not only the overflowing ones, so it belongs in its own issue 
rather than being folded into this one.

_Reported by Claude Code on behalf of Karol Krawczyk_

> simple predicate fails for long digital strings
> -----------------------------------------------
>
>                 Key: CAMEL-24407
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24407
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core
>    Affects Versions: 4.10.7, 4.18.2
>            Reporter: Ivan Ravin
>            Assignee: Karol Krawczyk
>            Priority: Major
>             Fix For: 4.18.5, 4.22.1, 4.23.0
>
>
> Simple language predicate fails with NumberFormatException when comparing 
> long digital strings (for example, bank accounts). It worked at least in 
> camel 2, but not in camel 4
> {code:java}
> from("timer:test?repeatCount=1&delay=1000")
> .setHeader("Account1").constant("12345678901234567890")
> .setHeader("Account2").constant("12345678901234567890")
> .filter().simple("${header.Account1} == ${header.Account2}")
>       .log(org.apache.camel.LoggingLevel.INFO, "Accounts equals")
> .end();
> {code}



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

Reply via email to