This is an automated email from the ASF dual-hosted git repository.

apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 25fdcff3a08e CAMEL-27594: camel-netty - Fix flaky test 
NettyProducerStrayExceptionTest
25fdcff3a08e is described below

commit 25fdcff3a08e99cede0b4ca34eef201c17f93be1
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Fri Nov 27 11:22:22 2026 +0100

    CAMEL-27594: camel-netty - Fix flaky test NettyProducerStrayExceptionTest
    
    The test adds an exceptionProbe handler to the pipeline of the channel that
    the producer opened at start, then releases the greeting of the test server.
    The channel is already registered on its event loop, so addBefore from the
    test thread returns before the handler is added: the event loop does it as a
    task. Under load the greeting can be decoded first, and the
    TooLongFrameException then skips the probe that is not in the pipeline yet.
    exceptionSeen is never counted down and the test fails with "the long
    greeting should fail in the decoder ==> expected: <true> but was: <false>".
    
    The test now sends the greeting only after the handlerAdded callback of the
    probe, and the timeouts of the awaits are raised for slow machines.
    
    Reproduced locally on the unchanged test with a repeated
    testServerCloseAfterExceptionOnUnusedChannel (60 runs) and 40 busy-loop
    processes: 28 of 62 runs failed with the error above and passed on rerun.
    With the change the same run passed 62 of 62.
    
    This is not the race of CAMEL-27568, which was the read timeout closing the
    unused channel.
    
    Co-authored-by: IBM Bob <[email protected]>
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../component/netty/NettyProducerStrayExceptionTest.java      | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyProducerStrayExceptionTest.java
 
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyProducerStrayExceptionTest.java
index a25539830829..157457b43e88 100644
--- 
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyProducerStrayExceptionTest.java
+++ 
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyProducerStrayExceptionTest.java
@@ -133,7 +133,13 @@ class NettyProducerStrayExceptionTest extends 
CamelTestSupport {
             channel.pipeline().remove("timeout");
         }
         // see the exception before the producer's handler gets it, and count 
down once that handler is done with it
+        CountDownLatch probeAdded = new CountDownLatch(1);
         channel.pipeline().addBefore("handler", "exceptionProbe", new 
ChannelInboundHandlerAdapter() {
+            @Override
+            public void handlerAdded(ChannelHandlerContext ctx) {
+                probeAdded.countDown();
+            }
+
             @Override
             public void exceptionCaught(ChannelHandlerContext ctx, Throwable 
cause) {
                 ctx.fireExceptionCaught(cause);
@@ -142,8 +148,11 @@ class NettyProducerStrayExceptionTest extends 
CamelTestSupport {
                 }
             }
         });
+        // the event loop adds the handler to the pipeline after addBefore 
returned, and a handler that is not added yet
+        // is skipped by an exception: send the greeting only when the probe 
is in place
+        assertTrue(probeAdded.await(10, TimeUnit.SECONDS), "the exception 
probe should be added to the pipeline");
         sendGreeting.countDown();
-        assertTrue(exceptionSeen.await(5, TimeUnit.SECONDS), "the long 
greeting should fail in the decoder");
+        assertTrue(exceptionSeen.await(15, TimeUnit.SECONDS), "the long 
greeting should fail in the decoder");
         assertTrue(channel.isActive(), "the channel stays open in the pool");
     }
 

Reply via email to