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

   JIRA: https://issues.apache.org/jira/browse/CAMEL-28110
   
   ## Problem
   
   `JettyEventNotifierTest` fails now and then with `expected: <2> but was: 
<1>`.
   
   `CamelServlet.afterProcess` writes the HTTP response first and only then 
calls `consumer.doneUoW(exchange)` in the `finally` block. The 
`ExchangeCompleted`/`ExchangeFailed` event is fired from there, so the client 
can receive the response and run its assertion before the last event is 
notified.
   
   ## Fix (test only)
   
   - Wait with Awaitility (`atMost` 10 seconds) for the full expected list of 
events instead of asserting right after the response. A failure now shows the 
actual events.
   - Use a `CopyOnWriteArrayList`, as the events are added from a Jetty thread 
and read from the test thread.
   
   ## Verification
   
   Reproduced by temporarily sleeping 500 ms in the listener for every event 
except `ExchangeCreated` (not committed):
   - before: `testEventNotifierOk` fails with `expected: <2> but was: <1>`
   - after: both tests pass
   
   Not found: why it became flakier recently. No change to the Jetty, 
`camel-http-common` or event notifier code in the last 10 days affects this 
ordering; most likely CI load.
   
   ---
   _Claude Code is not used here: this PR was written by IBM Bob (AI) 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