You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/01/07 08:44:44 UTC
[PR] Add ContextValue abstraction for ScopedValue support on JDK 25+ [camel]
gnodet opened a new pull request, #20702:
URL: https://github.com/apache/camel/pull/20702
## Summary
This PR introduces a new `ContextValue` abstraction that provides a unified API for thread-scoped data sharing, with implementations using either `ThreadLocal` (JDK 17+) or `ScopedValue` (JDK 25+ with virtual threads).
## Key Changes
### New ContextValue API
- Add `ContextValue` interface in camel-util with factory methods for creating context values and executing operations within scoped contexts
- Add `ContextValueFactory` with ThreadLocal implementation for base JDK
- Add Java 25 multi-release JAR variant using `ScopedValue` when available and virtual threads are enabled
### API Improvements in ExtendedCamelContext
- Add new scoped API methods with cleaner naming:
- `setupRoutes(Runnable)` and `setupRoutes(Callable<T>)`
- `createRoute(String, Runnable)` and `createRoute(String, Callable<T>)`
- `createProcessor(String, Runnable)` and `createProcessor(String, Callable<T>)`
- Deprecate the old boolean/void signaling methods (`setupRoutes(boolean)`, `createRoute(String)`, `createProcessor(String)`)
### Deprecations
- Deprecate `NamedThreadLocal` in favor of `ContextValue.newThreadLocal()`
### Implementation Updates
- Update `DefaultCamelContextExtension` to use `ContextValue.where()` for scoped execution
- Update `DefaultReactiveExecutor` to use `ContextValue` instead of `NamedThreadLocal`
- Simplify `Worker` class by removing cached `stats` field (now reads `statisticsEnabled` directly)
## Benefits
The `ContextValue` abstraction allows Camel to leverage `ScopedValue` on JDK 25+ when virtual threads are enabled, providing:
- Better performance characteristics for virtual thread workloads (no pinning)
- Immutable, inheritable values that work well with structured concurrency
- Backward compatibility with `ThreadLocal` on older JDK versions
## Documentation
Added documentation to `ContextValue` explaining that ThreadLocal variants should hold lightweight objects to avoid memory leaks with pooled threads.
---
Pull Request opened by [Augment Code](https://www.augmentcode.com/) with guidance from the PR author
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ContextValue abstraction for ScopedValue support on JDK 25+ [camel]
Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #20702:
URL: https://github.com/apache/camel/pull/20702#issuecomment-3719067905
I think its best to wait this kind of changes in core until after 4.18 LTS next month. Then we have an open path to do more bigger changes leading up for SB v4, Jackson 3, JUnit 6, Java 25 and other tasks that are more impactful.
Camel 4.18 LTS is expected to be similar to 4.14.x but as the last release supporting SB 3 that end users can use as a stable place.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ContextValue abstraction for ScopedValue support on JDK 25+ [camel]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #20702:
URL: https://github.com/apache/camel/pull/20702
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ContextValue abstraction for ScopedValue support on JDK 25+ [camel]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20702:
URL: https://github.com/apache/camel/pull/20702#issuecomment-3717861623
:star2: Thank you for your contribution to the Apache Camel project! :star2:
:robot: CI automation will test this PR automatically.
:camel: Apache Camel Committers, please review the following items:
* First-time contributors **require MANUAL approval** for the GitHub Actions to run
* You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot.
* You can label PRs using `build-all`, `build-dependents`, `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
* Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
* :warning: Be careful when sharing logs. Review their contents before sharing them publicly.
--
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: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org