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

   JIRA: https://issues.apache.org/jira/browse/CAMEL-27512
   
   ## Problem
   
   `MongoDbConsumerStopTest` (tailable and change streams consumers) failed 
about 8% of the runs with:
   
   ```
   AssertionFailedError: the consumer thread left behind is interrupted ==> 
expected: <true> but was: <false>
     at 
MongoDbConsumerStopTest.assertStopDoesNotWaitForTheBlockedThread(MongoDbConsumerStopTest.java:250)
   ```
   
   ## Cause
   
   `MongoAbstractConsumerThread.awaitStopped()` interrupts the consumer thread 
left behind and returns right away. The simulated blocked read sets 
`interruptedWhileReading` only once it wakes up from that interrupt, on the 
consumer thread. The test asserted the flag immediately after the stop 
returned, so it sometimes read it before the consumer thread had set it. The 
production code behaves as documented; only the test raced.
   
   ## Fix
   
   Wait for the flag with Awaitility (`atMost(10, SECONDS)`) instead of 
asserting it immediately. No production change.
   
   ## Verification
   
   Reproduced by delaying the setting of the flag by 300 millis in the 
simulated read (temporary, not committed):
   - before the fix: the tailable and change streams tests fail with the exact 
message above
   - with the fix: `MongoDbConsumerStopTest` passes (3 tests)
   
   Formatting checked with `mvn formatter:format impsort:sort` (no change).
   
   _Claude Code is not involved; this PR was prepared by IBM Bob 2.2.1 on 
behalf of @apupier._


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