From 095dadcbec7cd056ea1c0947d57d9084fae6d897 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 4 May 2018 07:36:33 +0200 Subject: [PATCH] Fix race in ChannelReadHandler used during LocalChannel testing. (#7904) Motivation: ChannelReadHandler is used in tests added via f4d7e8de140048047299808bb7e707c15342b826. In the handler we verify the number of messages we receive per read() call but missed to sometimes reset the counter which resulted in exceptions. Modifications: Correctly reset read counter in all cases. Result: No more unexpected exceptions when running LocalChannel tests. --- .../java/io/netty/channel/local/LocalChannelTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java b/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java index 628f621f4e..bbba9c52f7 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java +++ b/transport/src/test/java/io/netty/channel/local/LocalChannelTest.java @@ -1190,8 +1190,16 @@ public class LocalChannelTest { } else { read = 0; } + } else { + read = 0; } ctx.fireChannelReadComplete(); } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + ctx.fireExceptionCaught(cause); + ctx.close(); + } } }