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

   # CAMEL-28022: camel-cedar - a fractional number in the context or entity 
data gives an ERROR outcome
   
   ## Problem
   
   The `camel-cedar` component converts the `context` expression result, and 
the entity JSON that a
   `CedarEntityProvider` returns, to Cedar values with the Cedar Java object 
mapper. Cedar has no
   floating-point type: its value deserializer reads every in-range JSON number 
as a `Long`. A number that
   carries a fractional part (a `Double`, `Float` or `BigDecimal` such as 
`100.9`) was therefore converted to
   a whole number rather than carried faithfully, with no error. That 
contradicts the component's own
   documented behaviour, which tells authors that Cedar has no floating-point 
numbers and to use a whole
   number or a Decimal.
   
   ## Change
   
   - `CedarEvaluator` now walks the JSON tree of the context value, and of the 
provider entity JSON, before it
     is handed to the Cedar value deserializer, and gives the `ERROR` outcome 
when any number in the tree is not
     a whole number (`JsonNode.canConvertToExactIntegral()` is `false`).
   - A whole-valued number such as `100` or `100.0` is still accepted and 
evaluated as a `Long`, and a Cedar
     `Decimal`, whose digits are carried as a string, is unaffected.
   - The `context` and `entityProvider` option descriptions now state this 
behaviour, and the 4.25 upgrade
     guide records it.
   
   ## Tests
   
   `CedarEvaluatorTest` adds:
   
   - `fractionalContextNumberGivesErrorOutcome` - a `Double` with a fractional 
part in the context gives `ERROR`.
   - `bigDecimalFractionalContextGivesErrorOutcome` - a fractional `BigDecimal` 
gives `ERROR`.
   - `fractionalNumberNestedInContextCollectionGivesErrorOutcome` - a 
fractional number nested in a collection
     gives `ERROR`.
   - `fractionalEntityProviderAttributeGivesErrorOutcome` - a fractional entity 
attribute from a provider gives
     `ERROR`.
   - `wholeValuedDoubleContextIsAccepted` - a whole-valued `Double` is still 
accepted and evaluated.
   
   The tests run the real Cedar JNI engine and are gated to Linux amd64 with 
glibc, like the existing
   `CedarEvaluatorTest`.
   
   _Claude Code on behalf of oscerd_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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