davsclaus opened a new pull request, #27402:
URL: https://github.com/apache/camel/pull/27402

   _Claude Code on behalf of davsclaus_
   
   [CAMEL-25366](https://issues.apache.org/jira/browse/CAMEL-25366)
   
   Camel core had type converters from String, Number and byte[] to every 
numeric type except `java.math.BigDecimal`. Converting the String `"1000.01"` 
to `BigDecimal` therefore returned `null` without an error, and the simple 
language showed it as empty:
   
   - `${bodyAs(java.math.BigDecimal)}`
   - `${convertTo(${body}, java.math.BigDecimal)}`
   - `simple` with `resultType: java.math.BigDecimal`
   
   Comparisons such as `${body} > 1000` were not affected, because the 
comparison parses decimals itself (CAMEL-25013). That hid the gap. It showed up 
when an AI agent wrote a CSV order route with money amounts.
   
   ## Changes
   
   - `ObjectConverter.toBigDecimal(Object)`, next to `toBigInteger`:
     - a `String` becomes `new BigDecimal(text)`
     - a `BigInteger` is converted exactly
     - a `double` or `float` is converted from its decimal text, so `0.1` 
becomes `0.1`, not `0.1000000000000000055…`
     - other numbers go through `longValue()`
     - NaN gives `null`, the same as `toBigInteger`
   - Regenerated `CamelBaseBulkConverterLoader`.
   - Tests: `ObjectConverterTest.testToBigDecimal` and 
`SimpleTest.testBodyAsBigDecimal` (`bodyAs`, `convertTo` and result type).
   - Upgrade guide 4.23: a note that the conversion now works where it used to 
return `null`. For example, a bean method with a `BigDecimal` parameter can now 
be called with a `String` body.
   
   ## Testing
   
   - camel-core converter, simple and bean tests: 834 run, 0 failures.
   - The original YAML repro (`${bodyAs(java.math.BigDecimal)}` on `"1000.01"`) 
printed empty before and now prints `1000.01` with `camel run`.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01DDRLJAyf8cDXSg8iX785My
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to