From d870199c4e45f21b89ced0de77901f14e317efb0 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 21 Jan 2019 09:01:04 +0100 Subject: [PATCH] Fix flaky ChannelInitializerTest.testChannelInitializerEventExecutor() (#8738) Motivation: testChannelInitializerEventExecutor() did sometimes fail as we sometimes miss to count down the latch. This can happen when we remove the handler from the pipeline before channelUnregistered(...) was called for it. Modifications: Countdown the latch in handlerRemoved(...). Result: Fix flaky test. --- .../src/test/java/io/netty/channel/ChannelInitializerTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport/src/test/java/io/netty/channel/ChannelInitializerTest.java b/transport/src/test/java/io/netty/channel/ChannelInitializerTest.java index 38d867ab19..24e6b5e77f 100644 --- a/transport/src/test/java/io/netty/channel/ChannelInitializerTest.java +++ b/transport/src/test/java/io/netty/channel/ChannelInitializerTest.java @@ -338,7 +338,7 @@ public class ChannelInitializerTest { } @Override - public void channelUnregistered(ChannelHandlerContext ctx) { + public void handlerRemoved(ChannelHandlerContext ctx) { latch.countDown(); } }); @@ -372,6 +372,7 @@ public class ChannelInitializerTest { client.closeFuture().sync(); server.closeFuture().sync(); + // Wait until the handler is removed from the pipeline and so no more events are handled by it. latch.await(); assertEquals(1, invokeCount.get());