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

   ## Description
   
   Fixes the flaky `BoxEventsConsumerTest` 
(`listensAgainWhenTheEventStreamFails` and 
`continuesAfterTheLastEventsReceived`), added by CAMEL-27210 
(dc3e6f74ba2043bcd309ae300cca09c3c237103e).
   
   ### Cause
   
   The failures are a race in the test's fake Box connection, not in 
`BoxConsumer`:
   
   - the fake threw the simulated network error at once on the first request 
for events;
   - that request is sent by the poller thread of the Box SDK `EventStream`, 
which `EventStream.start()` starts **before** it sets `started = true`;
   - when the poller thread failed before the flag was set, 
`EventStream.notifyException()` calls `stop()`, which throws 
`IllegalStateException` as the stream is not started yet, and `onException` of 
the listener is never called;
   - `BoxConsumer` is then not notified, schedules no restart, and the mock 
endpoint receives fewer messages than expected (`Expected: <1> but was: <0>`, 
`Expected: <2> but was: <1>`).
   
   ### Fix
   
   The simulated network error now happens after a delay (500 ms), as a real 
one does, so the stream is started when it fails. The wait of the long poll and 
the wait of the network error share a `pause()` helper.
   
   The race itself is in the Box SDK (`started = true` set after the poller 
thread start); the delay makes it very unlikely in the test.
   
   ### Testing
   
   `BoxEventsConsumerTest` passes (4 tests), also repeated under CPU load.
   
   Target: `main`
   
   # Tracking
   - [x] [CAMEL-27643](https://issues.apache.org/jira/browse/CAMEL-27643)
   
   ---
   _Claude Code on behalf of @apupier_ (AI-generated with IBM Bob)


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