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

   Fixes [CAMEL-26510](https://issues.apache.org/jira/browse/CAMEL-26510).
   
   Twin of #29019 
([CAMEL-26195](https://issues.apache.org/jira/browse/CAMEL-26195)), which makes 
the same fix in camel-opentelemetry-metrics.
   
   ### A counter increment or decrement that does not give a number added 1
   
   `CounterProducer` evaluates the `increment` and `decrement` options as 
simple expressions converted to `Double`, and the
   `CamelMetricsCounterIncrement` / `CamelMetricsCounterDecrement` headers 
override them. When both ended up `null`, it
   fell through to `counter.increment()`. So with `increment=${body}` a body 
`"42"` added 42, but a `Map`, `List`, POJO or
   `null` body (or a missing header with `increment=${header.amount}`) silently 
added 1.
   
   Change: when `increment` or `decrement` is set, but neither of them (nor the 
headers) gives a number, the producer fails
   the exchange with an `IllegalArgumentException` naming the expressions and 
the counter, and does not update the
   counter. Same rule and message as #29019:
   
   - A counter with neither option still adds 1, as documented.
   - `increment=${header.inc}&decrement=${header.dec}` with only one of the two 
headers set per message keeps working: the
     check is only made when both give nothing.
   
   ### Tests
   
   `CounterRouteTest` (JUnit assertions, as in the module):
   
   - `increment=${body}` with `"42"` adds 42.
   - `increment=${body}` with a `Map`, `List`, POJO and `null` body fails with 
`IllegalArgumentException`, and the counter
     stays at 0.
   - `increment=${header.inc}&decrement=${header.dec}`: one header set per 
message works (10 - 3 = 7); no header fails and
     the counter stays at 0.
   - A counter with no options adds 1 per message.
   
   The two failing-case tests failed before the fix (nothing was thrown). 
Module: 111 tests pass, with `-Psourcecheck`.
   
   ### Docs and generated files
   
   - Component doc: a sentence on the failure when the options do not give a 
number; catalog doc copy updated.
   - Upgrade guide 4.24: a `camel-micrometer` entry, as routes that relied on 
the add-1 fall-through now fail.
   
   ### Not changed
   
   - The header `javaType` is correct here: camel-micrometer documents 
`CamelMetricsCounterIncrement` /
     `CamelMetricsCounterDecrement` as `Double` and reads them as `Double` 
(#29019 had to change otel's from `Double` to
     `long`). So no component JSON or Endpoint DSL change.
   - `DistributionSummaryProducer` skips the record when `value` gives no 
number (it does not invent a value), so it is
     left as is.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 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