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

   Fixes [CAMEL-26195](https://issues.apache.org/jira/browse/CAMEL-26195).
   
   ### 1. 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 `Long`. When
   neither gave a number, it fell through to `counter.add(1)`. So with 
`increment=${body}` a body `"42"` added 42, a body
   `"text"` failed with a `TypeConversionException`, 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 
`CamelMetricsCounterIncrement` /
   `CamelMetricsCounterDecrement` header) gives a number, the producer fails 
the exchange with an
   `IllegalArgumentException` naming the expressions and the counter, and does 
not update the counter. A counter with
   neither option still adds 1. A route with 
`increment=${header.inc}&decrement=${header.dec}` that sets only one of the
   two headers per message keeps working: the check is only made when both give 
nothing.
   
   ### 2. The counter headers were documented as Double
   
   `OpenTelemetryConstants` documented `CamelMetricsCounterIncrement` and 
`CamelMetricsCounterDecrement` with
   `javaType = "Double"`, but `CounterProducer` reads them as `Long`. They are 
now `long`, like
   `CamelMetricsHistogramValue`.
   
   ### Tests
   
   `CounterRouteTest`: new tests for `increment=${body}` with a number text 
(adds 42), with a `Map`, `List`, POJO and
   `null` body (fails, counter not updated), and for 
`increment=${header.inc}&decrement=${header.dec}` with one header
   set (works) and with none (fails). The two failing-case tests failed before 
the fix (nothing was thrown). Module: 93
   tests and 5 ITs pass, with `-Psourcecheck`.
   
   ### Docs and generated files
   
   - Component doc: a sentence on the failure when the options do not give a 
number.
   - Upgrade guide 4.24: an entry under `camel-opentelemetry-metrics`, as 
routes that relied on the add-1 fall-through
     now fail.
   - Regenerated: component JSON, catalog JSON and doc copy, and 
`OpenTelemetryEndpointBuilderFactory` (header javadoc
     type).
   
   ### Not changed
   
   - `camel-micrometer` `CounterProducer` has the same fall-through. It is a 
different component, so it is left for its
     own issue.
   - Failing was chosen over skipping the update, as a body such as `"text"` 
already fails with a
     `TypeConversionException`, and a silent skip would hide the 
misconfiguration the same way the add-1 did.
   
   _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