CAMEL-24320: Fix Kamelet route creation with virtual threads on JDK 25 - #25265
CAMEL-24320: Fix Kamelet route creation with virtual threads on JDK 25#25265atiaomar1978-hub wants to merge 3 commits into
Conversation
Make ScopedValue-backed ContextValue.orElse null-tolerant so getCreateRoute()/getCreateProcessor() can return null outside a binding scope. Add regression tests for the ScopedValue path and Kamelet startup. Co-authored-by: Cursor <cursoragent@cursor.com>
|
AI-generated comment on behalf of atiaomar1978-hub Review follow-up (Bugbot + Grok)Independent reviews were run on branch BugbotNo bugs found. Grok findings
Reproduction confirmed per JIRA: NPE at Ready for review. |
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
need to format: |
| static { | ||
| System.setProperty("camel.threads.virtual.enabled", "true"); | ||
| } | ||
|
|
||
| @AfterEach | ||
| void resetThreadType() throws Exception { | ||
| Field field = ThreadType.class.getDeclaredField("current"); | ||
| field.setAccessible(true); | ||
| field.set(null, null); | ||
| System.clearProperty("camel.threads.virtual.enabled"); | ||
| } |
There was a problem hiding this comment.
need to look for the value of the property before the test and reset it to thsi value after
There was a problem hiding this comment.
Fixed in 58bc2359d1d — @BeforeEach saves the previous camel.threads.virtual.enabled value and @AfterEach restores it (clear when previously unset).
| @Isolated | ||
| @EnabledForJreRange(min = JRE.JAVA_25) | ||
| class KameletVirtualThreadsRouteCreationTest { |
There was a problem hiding this comment.
There was a problem hiding this comment.
Fixed in 58bc2359d1d — replaced @Isolated with @ResourceLock(Resources.SYSTEM_PROPERTIES) on the test class.
| main.start(); | ||
| assertThat(main.getCamelContext().getRoute("vt-kamelet-repro")).isNotNull(); | ||
| main.stop(); | ||
| }).doesNotThrowAnyException(); |
There was a problem hiding this comment.
there is already an assertion in the test, not sure it is necessary to use doesNotThorwAnyException. If an exception is thrown, it will be reorted as an error already by the test
There was a problem hiding this comment.
Fixed in 58bc2359d1d — removed assertThatCode; the test now uses direct assertions and a try/finally around main.stop().
|
AI-generated comment on behalf of atiaomar1978-hub Fixed the sourcecheck failure in run 30603239831 ( The build reformatted javadoc line wrapping in Re-ran Please re-run or wait for CI on the latest commit. |
Fix sourcecheck uncommitted-changes failure from javadoc line wrapping. Co-authored-by: Cursor <cursoragent@cursor.com>
Save and restore camel.threads.virtual.enabled, use ResourceLock for system properties instead of @isolated, and drop redundant assertThatCode wrapper. Co-authored-by: Cursor <cursoragent@cursor.com>
|
AI-generated comment on behalf of atiaomar1978-hub Addressed @apupier review in
Re-ran Ready for re-review. |
Summary
AI-generated on behalf of atiaomar1978-hub
Fixes CAMEL-24320: with
-Dcamel.threads.virtual.enabled=trueon JDK 25+, Kamelet route creation failed during endpoint init with an NPE.Root cause: the JDK 25
ScopedValue-backedContextValue.orElse(null)delegated toScopedValue.orElse, which rejects a null fallback viaObjects.requireNonNull.DefaultCamelContextExtension.getCreateRoute()/getCreateProcessor()callorElse(null)outside any binding scope (e.g. fromKameletComponent.doInit).Fix: make
ScopedValueContextValue.orElsenull-tolerant — return the default when unbound instead of delegating toScopedValue.orElse.Tests
ScopedValueContextValueOrElseTest(JDK 25+): direct regression for null/default/boundorElseon the ScopedValue backendCreateContextValueTest:getCreateRoute()/getCreateProcessor()return null outside scopeKameletVirtualThreadsRouteCreationTest(JDK 25+): Main starts a route consumingkamelet:vt-repro-sourcewith virtual threads enabledTest plan
mvn test -pl core/camel-util,core/camel-core,components/camel-kamelet -am -Dtest=ContextValueTest,ScopedValueContextValueOrElseTest,CreateContextValueTest,KameletVirtualThreadsRouteCreationTestScopedValueContextValueOrElseTestJIRA: https://issues.apache.org/jira/browse/CAMEL-24320
Made with Cursor