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

   ## CAMEL-24903: Fix flaky ThrottlingExceptionRoutePolicyOpenViaConfigTest
   
   ### Root Cause
   
   With `concurrentConsumers=20` on the SEDA endpoint, a round-1 
`onExchangeDone()` callback could fire **after** `policy.setKeepOpen(true)` was 
called by the test thread. The callback saw `keepOpenBool=true` and called 
`openCircuit()`, which suspended the consumer **before** the `MessageTrigger` 
message was picked up from the SEDA queue. This caused the 
`expectedMessageCount(6)` assertion to fail with count 5.
   
   The prior fix (CAMEL-24035, commit `72a2aa1`) was cosmetic only (removed 
`public` modifiers, added a timeout constant) and did not address the race.
   
   ### Fix
   
   Two-pronged approach to eliminate the race entirely:
   
   **1. Production code (`ThrottlingExceptionRoutePolicy.setKeepOpen`)**
   
   `setKeepOpen(true)` now immediately opens the circuit via 
`openCircuit(route)` instead of waiting for the next `onExchangeDone()` 
callback. This makes the `keepOpen` toggle synchronous and deterministic — 
callers no longer need to send a trigger message to activate it.
   
   **2. Test reordering**
   
   `MessageTrigger` is now sent and fully awaited (via `assertIsSatisfied`) 
**before** `setKeepOpen(true)` is called. This guarantees the trigger is 
consumed while the circuit is still closed. `setKeepOpen(true)` then suspends 
the consumer immediately (via the production fix), so no subsequent messages 
can slip through.
   
   ### Test Results
   
   - `ThrottlingExceptionRoutePolicyOpenViaConfigTest` — GREEN (3 consecutive 
runs)
   - All `ThrottlingException*` tests — GREEN
   
   _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