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

   ## Summary
   
   _Claude Code on behalf of davsclaus_
   
   Fixes thread-safety issues in camel-xslt stylesheet reload 
(`contentCache=false` / `clearCachedStylesheet` JMX operation) where stale 
pooled transformers keep serving the old stylesheet after a reload.
   
   ### Problems fixed
   
   1. **Stale pooled transformers survive reload** — with `transformerCacheSize 
> 0`, a `Transformer` borrowed before `setTemplate()` is re-offered to the pool 
after the transform completes, causing the old stylesheet to be served 
indefinitely
   2. **`XsltBuilder.template` not volatile** — plain field with no visibility 
guarantee across threads
   3. **Shared `TransformerFactory` used concurrently** — 
`setTransformerSource()` mutates error listener/URI resolver and calls 
`newTemplates()` without synchronization; JAXP does not guarantee 
`TransformerFactory` thread safety
   4. **Redundant parallel reloads** — `cacheCleared` flag reset only after 
full load; concurrent messages trigger redundant stylesheet compilations
   
   ### Changes
   
   - **`XsltBuilder`**: make `template` volatile; add `AtomicLong 
templateGeneration` counter incremented on every `setTemplate()` call; in 
`releaseTransformer()`, discard the transformer if its generation doesn't match 
current (prevents stale re-entry); wrap `setTransformerSource()` with a 
`ReentrantLock` to serialize `TransformerFactory` access
   - **`XsltEndpoint`**: add `ReentrantLock reloadLock` with double-checked 
locking around `loadResource()` in `onExchange()` to prevent redundant parallel 
reloads
   
   ## Test plan
   
   - [x] New `XsltBuilderReloadTest` with 3 tests: basic pool invalidation on 
template change, multiple reloads, concurrent processing after reload
   - [x] All existing XSLT tests pass (`XsltBuilderTest`, `XsltTest`, 
`XsltRouteTest`)
   - [x] Full `camel-core` test suite passes
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   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