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

   ## Summary
   
   Fixes two distinct bugs where `camel.main.virtualThreadsEnabled=true` failed 
to enable virtual threads:
   
   - **Race condition (properties file path)**: `autoconfigure()` set the 
system property `camel.threads.virtual.enabled` *after* `camelContext.build()` 
had already triggered `ThreadType.current()`, which uses a permanent 
double-checked-locking cache. Once cached as `PLATFORM`, the value was never 
re-evaluated.
   - **Programmatic path always broken**: 
`main.configure().withVirtualThreadsEnabled(true)` set 
`mainConfigurationProperties.virtualThreadsEnabled=true` but 
`autoConfigurationSingleOption` only reads external sources — the system 
property was never set, so `ThreadType.current()` always returned `PLATFORM`.
   
   **Fix:**
   
   1. Add `configureVirtualThreadsEarly()` to `BaseMainSupport`, called 
*before* `camelContext.build()`. It checks all config sources in priority 
order: programmatic → `initialProperties` → `PropertiesComponent` 
(application.properties) → ENV vars → JVM system props.
   2. Add `ThreadType.enable()` in `camel-util` to directly set the cached 
value to `VIRTUAL`, overriding any value that may have been cached earlier in 
the bootstrap sequence.
   3. New test class `MainVirtualThreadsTest` covering both previously-broken 
paths.
   
   ## Test plan
   
   - [ ] `MainVirtualThreadsTest.testProgrammaticVirtualThreadsEnabled` — 
verifies `main.configure().withVirtualThreadsEnabled(true)` correctly sets 
`ThreadType.VIRTUAL`
   - [ ] `MainVirtualThreadsTest.testInitialPropertyVirtualThreadsEnabled` — 
verifies `main.addInitialProperty("camel.main.virtualThreadsEnabled", "true")` 
correctly sets `ThreadType.VIRTUAL`
   - [ ] Both tests pass in isolation and as part of the full `camel-main` test 
suite
   
   Relates to: https://issues.apache.org/jira/browse/CAMEL-23479
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 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]

Reply via email to