[backport camel-4.22.x] CAMEL-24407: simple predicate fails for long digital strings - #25978
Conversation
Numbers with more digits than a long can hold, such as bank account numbers, made comparisons throw NumberFormatException. isNumber only checks that the text is all digits, and the callers then parsed it with Long.parseLong or Integer.valueOf. Compare those as BigInteger instead. A number that does not fit in a long can never equal an int or long, so equality with one is false. A numeric literal in a simple predicate that does not fit in a long is now kept as literal text, so it takes the same comparison path. Co-authored-by: Claude <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 555 tested, 29 compile-only — current: 555 all testedMaveniverse Scalpel detected 584 affected modules (current approach: 555).
|
gnodet
left a comment
There was a problem hiding this comment.
Straight cherry-pick backport of #25945 (CAMEL-24407) to camel-4.22.x. Content is identical to the original PR which was already reviewed and approved — only hunk offsets differ due to different base branch. LGTM.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
Backport of #25945
Cherry-pick of #25945 onto
camel-4.22.x.Original PR: #25945 - CAMEL-24407: simple predicate fails for long digital strings
Original author: @k-krawczyk
Target branch:
camel-4.22.xOriginal description
The
simplelanguage throwsNumberFormatExceptionwhen it compares numbers with more digitsthan a long can hold, such as bank account numbers.
ObjectHelper.isNumberonly checks that thetext is all digits, and the callers then parse it with
Long.parseLongorInteger.valueOf.String to String comparisons fall back to
BigIntegerwhen the value does not fit in a long.A number outside the long range can never equal an int or a long, so equality against one is
false, and ordering against one is decided asBigInteger. A numeric literal in a predicatethat does not fit in a long is now kept as literal text, so it takes the same comparison path
as a header would.
See #25945 for full details, reproduction and test coverage.
This is a straight cherry-pick with no manual conflict resolution; the change was already
reviewed and merged on
main.Claude Code on behalf of davsclaus