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

   # Description
   
   [CAMEL-27566](https://issues.apache.org/jira/browse/CAMEL-27566)
   
   Backport of #30862 (CAMEL-27566) to camel-4.22.x.
   
   A `FileLockClusterView` member that lost the leadership reads its own id in 
the data file and tries to take the leadership back. If that one attempt 
failed, it kept its own id as the previous observation and every later check 
took the backoff return, so a single-member cluster stayed without a leader 
until a restart. `camel-4.22.x` has the same backoff. The fix is the same as on 
main: the backoff lasts one check (`compareAndSet(latestClusterLeaderInfo, 
null)`), so the next check tries the lock again.
   
   What differs from main:
   - `FileLockClusterView`: no difference, the change is the same lines as on 
main.
   - `FileLockClusterViewReclaimLeadershipTest`: this branch has no 
`resolveLockPathKey()` (it came with CAMEL-27322), so, as suggested in the 
review of #30862, the test makes the first attempt to take the leadership back 
fail in `createRandomAccessFile` (one simulated failure, thrown as the 
`ExecutionException` the task executor reports) instead. Since that override is 
not retried by the task executor, the test no longer sets 
`clusterDataTaskMaxAttempts`. The rest of the test is the same as on main.
   - CAMEL-27567 is not part of this backport (it needs CAMEL-27322).
   
   Tests on `camel-4.22.x` (offline, `core/camel-core` and 
`components/camel-file` with `-am`): all 
`org.apache.camel.component.file.cluster` tests pass, 24 run, 0 failures 
(`FileLockClusterViewReclaimLeadershipTest` 2, 
`FileLockClusteredRoutePolicyTest` 1, `FileLockClusteredRoutePolicyFactoryTest` 
5, `FileLockClusterUtilsTest` 13, `FileLockClusterTaskExecutorTest` 3). 
`FileLockClusterViewReclaimLeadershipTest` 40/40 over 20 runs. Negative 
control: with the `camel-4.22.x` `FileLockClusterView` (without the fix), 
`memberTakesTheLeadershipBackAfterAFailedAttempt` fails in 3 of 3 runs (the 
member never takes the leadership back), and the control test 
`memberTakesTheLeadershipBackAtOnce` passes.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (this is a 
backport to `camel-4.22.x`)
   
   # 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): 
[CAMEL-27566](https://issues.apache.org/jira/browse/CAMEL-27566).
   
   # 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 camel-core and camel-file of `camel-4.22.x` with the formatter 
and import-sort plugins and ran the tests above; no generated file changes. 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.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 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