gnodet opened a new pull request, #25160: URL: https://github.com/apache/camel/pull/25160
## Summary _Claude Code on behalf of gnodet_ `DefaultTracer.traceCounter` was a plain `long` incremented with `++` in `traceBeforeNode()`, which is called from concurrent routing threads. The `++` operator is a compound read-modify-write — a classic lost-update race under contention. This causes the trace counter to undercount when multiple routes execute concurrently. **Fix:** Switch `traceCounter` from `private long` to `private final AtomicLong`, consistent with `BacklogTracer` which already uses `AtomicLong` for the identical purpose. ### Changes - `DefaultTracer.java`: Change `traceCounter` field from `long` to `AtomicLong`; update `traceBeforeNode()` (`++` → `incrementAndGet()`), `getTraceCounter()` (direct read → `.get()`), and `resetTraceCounter()` (assignment → `.set(0)`) - New test: `DefaultTracerTraceCounterConcurrencyTest` — verifies counter accuracy with 8 threads × 250 messages, and validates `resetTraceCounter()` ### Context CAMEL-24227 previously fixed JMM-unsafe volatile patterns in `DefaultTracer` (boolean fields, trace pattern holder) but left `traceCounter` as a plain `long`. This PR completes that thread-safety work. ## Test plan - [x] New `DefaultTracerTraceCounterConcurrencyTest` passes (2 tests: concurrent accuracy + reset) - [x] Existing `ManagedTracerTest` not broken by change (pre-existing compilation issue in `camel-management` module is unrelated — `ManagedRoute.java` method signature mismatch) - [x] `sourcecheck` formatting validation passes - [ ] CI build 🤖 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]
