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

   # Description
   
   [CAMEL-24922](https://issues.apache.org/jira/browse/CAMEL-24922)
   
   With `loadBalance().failover(-1, false, false, true)` (sticky, no round 
robin), the failover load balancer starts each exchange at the last known good 
endpoint and only moves forward. At the end of the list it gave up, so the 
endpoints before the last known good one were never tried again. Once that 
endpoint went down, every exchange failed, although other endpoints were up and 
`maximumFailoverAttempts` was `-1`. With `roundRobin=true` the same scenario 
recovered.
   
   This change: in sticky mode without round robin, when the end of the list is 
reached, failover continues from the first endpoint and stops once every 
endpoint has been tried once for the exchange. Sticky with round robin, and 
non-sticky modes, are unchanged.
   
   Tests: new `FailoverStickyWrapAroundTest`:
   - `testFailoverStickyContinuesFromFirstEndpoint`: `c` becomes the last good 
endpoint; then `c` goes down and `a` comes up. The exchange must fail over from 
`c` to `a`, and `a` becomes the new last good endpoint.
   - `testFailoverStickyTriesEachEndpointOnceWhenAllDown`: with all endpoints 
down, each is tried exactly once and the exchange fails. There's no endless 
loop.
   
   Without the fix, both tests fail (`mock://b Received message count. 
Expected: <1> but was: <0>`). With the fix, they pass together with the 
existing failover tests (`Failover*Test`, `FailOver*Test`: 21 tests, 0 
failures).
   
   Found with a Lean 4 model of `FailOverLoadBalancer` (a proof that sticky 
mode tries every endpoint failed, which gave this counterexample), then 
reproduced against the real classes.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested the affected modules, `camel-core-processor` and 
`camel-core`, including the formatter and import-sort plugins. I did not run 
the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   


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