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

   ## Summary
   
   Fix two bugs in `SedaEndpoint` where user-set parameter values were silently 
overridden:
   
   1. **Size bug**: When `size=1000` (the SEDA default value) or 
`size=Integer.MAX_VALUE` was explicitly set in the endpoint URI, `getQueue()` 
and `registerQueueIfStale()` treated those values as "not set" and replaced 
them with the component default. Any user-set size that happened to equal 
`SedaConstants.QUEUE_SIZE` (1000) or `Integer.MAX_VALUE` was silently ignored.
   
   2. **Virtual thread `concurrentConsumers` bug**: `doInit()` reset 
`concurrentConsumers` from 1 to 0 whenever `virtualThreadPerTask=true`, 
regardless of whether the user had explicitly set `concurrentConsumers=1`. This 
made it impossible to intentionally limit virtual thread concurrency to 1.
   
   ## Root Cause
   
   Both bugs used magic-value comparisons to detect "not set":
   - `(getSize() == Integer.MAX_VALUE || getSize() == SedaConstants.QUEUE_SIZE) 
? null : getSize()` — a user-set value of 1000 or `Integer.MAX_VALUE` was 
indistinguishable from the unset default.
   - `if (virtualThreadPerTask && concurrentConsumers == 1)` — a user-set value 
of 1 was indistinguishable from the initial default.
   
   ## Fix
   
   Replace the magic-value comparisons with explicit boolean sentinel flags:
   
   - `sizeSet`: set to `true` by `setSize(int)` (the user-facing setter). 
Internal size syncing from the queue reference uses direct field assignment 
(`this.size = ref.getSize()`) so as not to pollute the flag.
   - `concurrentConsumersSet`: set to `true` by `setConcurrentConsumers(int)`. 
A new package-private `setConcurrentConsumersDefault(int)` is added for 
`SedaComponent` to propagate its configured default without marking the value 
as user-set.
   - `SedaComponent.createEndpoint()` now records whether `concurrentConsumers` 
was explicitly present in the URI parameters before consuming them, and routes 
to the appropriate setter.
   
   ## Tests
   
   `SedaSizeSentinelTest` adds four regression tests:
   - `testExplicitSizeOfDefaultValueIsRespected`: size=1000 is preserved when 
the component default differs.
   - `testExplicitSizeMaxValueIsRespected`: size=Integer.MAX_VALUE is preserved 
when the component default differs.
   - `testConcurrentConsumersOneWithVirtualThreadsIsRespected`: 
concurrentConsumers=1 with virtualThreadPerTask=true is preserved.
   - `testConcurrentConsumersDefaultsToZeroWithVirtualThreads`: without 
explicit concurrentConsumers, virtualThreadPerTask=true still defaults to 0 
(pre-existing behaviour, now correctly gated).
   - `testVirtualThreadsWithConcurrentConsumersOneProcessesMessages`: 
end-to-end route smoke test.
   
   Fixes CAMEL-27896
   
   ---
   _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
   


-- 
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