gnodet opened a new pull request, #21703: URL: https://github.com/apache/camel/pull/21703
## Summary - Replace `synchronized` blocks/methods with `ReentrantLock` or better concurrent data structures across core modules and components to prevent virtual thread pinning (JDK 21+) - Virtual threads get pinned to carrier threads when entering `synchronized` blocks, degrading throughput. `ReentrantLock` does not cause pinning. - Where possible, use lock-free data structures instead of locks: `ConcurrentLinkedQueue`, `CopyOnWriteArrayList`, `volatile` with double-checked locking ### Core changes | File | Change | |------|--------| | `Suppliers.java` | `synchronized` → `ReentrantLock` for memoization | | `DefaultModel.java` | 9 `synchronized` methods → single `ReentrantLock` (reentrant for nested calls) | | `DefaultCamelContext.java` | `synchronized(model)` → uses `DefaultModel`'s lock | ### Component changes | Component | Change | |-----------|--------| | `camel-aws2-sqs` | `volatile` + `ReentrantLock` double-checked locking, removed redundant `queueUrlInitialized` flag | | `camel-mock` | `synchronized` → `ReentrantLock` | | `camel-google-firestore` | `synchronized` + `LinkedList` → `ConcurrentLinkedQueue` (lock-free) | | `camel-google-pubsub` | `synchronizedList` → `CopyOnWriteArrayList` (lock-free) | | `camel-milo` | 12 `synchronized` constructs → `ReentrantLock` across `SubscriptionManager`, `MiloClientConnection`, `CamelNamespace` | ### Intentionally skipped - `CxfConsumer`: synchronizes on per-request `continuation` object — brief pinning, CXF API constraint - `KameletComponent`, `CamelWebSocketHandler`: already use `ReentrantLock` - XML converters: per-document synchronization, brief lock scope - ThreadLocal usages: same-thread semantics, work correctly with virtual threads ## Test plan - [ ] Existing unit tests pass for all modified modules - [ ] CI build passes (formatting, sourcecheck) - [ ] Verify no regressions in core routing tests 🤖 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]
