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

   # Description
   
   Fixes the flaky `NettyProducerStrayExceptionTest` (CAMEL-27594). It failed 
on CI with:
   
   ```
   org.opentest4j.AssertionFailedError: the long greeting should fail in the 
decoder ==> expected: <true> but was: <false>
        at 
NettyProducerStrayExceptionTest.startProducerAndAwaitException(NettyProducerStrayExceptionTest.java:141
 / 146)
   ```
   
   ## Cause
   
   `startProducerAndAwaitException` adds an `exceptionProbe` handler to the 
pipeline of the channel the producer opened at start, then releases the 
greeting of the test server. The channel is already registered on its event 
loop, so `pipeline().addBefore(...)` called from the test thread returns before 
the handler is in the pipeline: the event loop adds it as a task. On a loaded 
machine the greeting can be decoded first, and the `TooLongFrameException` then 
skips the probe that is not added yet. `exceptionSeen` is never counted down 
and the test fails.
   
   This is not the race fixed by CAMEL-27568 (the read timeout closing the 
unused channel).
   
   ## Change
   
   Test only:
   - the probe counts down a `probeAdded` latch in `handlerAdded`, and the test 
sends the greeting only after it
   - the awaits are raised (probe 10 s, exception 15 s) for slow machines
   
   ## Reproduction
   
   On the unchanged test, with `testServerCloseAfterExceptionOnUnusedChannel` 
repeated 60 times and 40 busy-loop processes on the CPU: 28 of 62 runs failed 
with the error above (they passed on the surefire rerun). With this change the 
same run passed 62 of 62. Without load, the unchanged test passed 62 of 62, 
which is why it is flaky only on busy CI machines.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] I checked there is a [JIRA 
issue](https://issues.apache.org/jira/browse/CAMEL-27594) filed for the change.
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [x] I have run `mvn formatter:format impsort:sort` on the module; only a 
test class changed, so there are no generated changes.
   
   # AI-assisted contributions
   
   - [x] This PR was written with AI assistance: the commit has a 
`Co-authored-by` trailer, and the diagnosis, the fix and the reproduction were 
done by IBM Bob on behalf of @apupier.
   
   _IBM Bob on behalf of Aurélien Pupier (@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