gnodet opened a new pull request, #26193: URL: https://github.com/apache/camel/pull/26193
## Problem `JGroupsRaftProducerTest.shouldSendBody` is flaky due to a Raft leader-election timing race. `waitForLeader()` only checks that one node considers itself leader (`isLeader()`), but does NOT wait for follower nodes to learn who the leader is. When `template.request()` hits a non-leader node whose REDIRECT protocol has not yet discovered the leader, `set()` throws a `RaftLeaderException`. This exception propagates before `populateJGroupsRaftHeaders()` executes (line 81 in `JGroupsRaftProducer.process()`), so all headers remain null, causing `assertNotNull` to fail. ## Fix 1. **Make `waitForLeader()` check `leader() != null` on ALL handles** — ensures every node has discovered the leader before the test proceeds with `set()` calls 2. **Replace `Thread.sleep()` with Awaitility** — per project conventions (CLAUDE.md), with 500ms poll interval for faster convergence 3. **Increase timeout from 5 to 30 seconds** for producer and consumer tests (the cluster test already used 50s) 4. **Apply the same fix to `JGroupsRaftClusterAbstractTest`** which had the identical bug ## Changes - `JGroupsRaftAbstractTest.waitForLeader()`: Awaitility + `leader() != null` check on all handles - `JGroupsRaftClusterAbstractTest.waitForLeader()`: Same fix - `JGroupsRaftProducerTest`: timeout 5 → 30 - `JGroupsRaftConsumerTest`: timeout 5 → 30 _AI agent (Hermes on behalf of gnodet)_ -- 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]
