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

   _Claude Code on behalf of gnodet_
   
   ## Summary
   
   An audit of the Camel management layer revealed a systemic JMM-unsafe 
pattern across **12 engine classes (~50 fields)**. Fields writable via JMX 
`@ManagedAttribute` setters are stored as plain (non-volatile) fields in engine 
classes, but read on routing threads without any memory visibility guarantee.
   
   ### Fix approach
   
   - **Simple boolean/int/long fields**: added `volatile`. On x86 this compiles 
to the same instruction as a plain load, so there is **zero performance cost**. 
On ARM/POWER architectures with weaker memory ordering, this provides the 
required happens-before guarantee.
   
   - **Compound writes** (`tracePattern`+`patterns`, `traceFilter`+`predicate` 
in `BacklogTracer`/`DefaultTracer`): replaced the two separate fields with an 
**immutable holder record** swapped atomically via a single volatile reference, 
ensuring routing threads always see a consistent pair.
   
   ### Affected classes (12 files)
   
   | Engine class | Fields made volatile | Hot path |
   |---|---|---|
   | `BacklogTracer` | `enabled`, `standby`, `bodyMaxChars`, 
`bodyIncludeStreams`, `bodyIncludeFiles`, `includeExchangeProperties`, 
`includeExchangeVariables`, `includeException`, `backlogSize`, `activitySize`, 
`removeOnDump`, `activityEnabled`, `traceRests`, `traceTemplates` + holder 
records for `tracePattern`+`patterns` and `traceFilter`+`predicate` | 
`shouldTrace()`, `traceNode()` |
   | `DefaultTracer` | `enabled`, `standby`, `traceRests`, `traceTemplates`, 
`traceBeforeAndAfterRoute` + holder record for `tracePattern`+`patterns` | 
`shouldTrace()` |
   | `BaseProcessorSupport` | `disabled` | `CamelInternalProcessor.process()` |
   | `DefaultBacklogDebugger` | `fallbackTimeout`, `bodyMaxChars`, 
`bodyIncludeStreams`, `bodyIncludeFiles`, `includeExchangeProperties`, 
`includeExchangeVariables`, `includeException`, `singleStepIncludeStartEnd` | 
`NodeBreakpoint.beforeProcess()` |
   | `TotalRequestsThrottler` | `timePeriodMillis` | `process()` |
   | `AbstractThrottler` | `maxRequestsExpression` | `process()` |
   | `DefaultStreamCachingStrategy` | `spoolThreshold`, 
`spoolUsedHeapMemoryThreshold`, `anySpoolRules`, `bufferSize` | 
`shouldSpoolCache()` |
   | `ThrottlingInflightRoutePolicy` | `maxInflightExchanges`, 
`resumePercentOfMax`, `resumeInflightExchanges`, `scope` | `throttle()` |
   | `ThrottlingExceptionRoutePolicy` | `halfOpenAfter`, `failureWindow`, 
`failureThreshold` | `calculateState()` |
   | `ManagedPerformanceCounter` | `statisticsEnabled` | 
`DefaultInstrumentationProcessor.before()` |
   | `ScheduledPollConsumer` | `greedy`, `sendEmptyMessageWhenIdle`, `delay`, 
`runLoggingLevel` | `doRun()` |
   | `Delayer` | `delay` | `calculateDelay()` |
   
   ## Test plan
   
   - [x] All 12 affected modules compile successfully
   - [x] 156 core tests pass (throttler, backlog tracer, stream caching, 
scheduled poll, delayer)
   - [x] 39 management tests pass (BacklogTracer, BacklogDebugger, Tracer, 
PerformanceCounter)
   - [x] Code formatting verified clean (`formatter:format` + `impsort:sort` 
reports no changes)
   - [ ] Full CI
   
   Co-Authored-By: Claude Opus 4.6 <[email protected]>


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