From a25101dd0bb040d340b999dcec48953314202182 Mon Sep 17 00:00:00 2001 From: Scott Mitchell Date: Mon, 21 Nov 2016 10:46:21 -0800 Subject: [PATCH] Now that LocalChannel#releaseInboundBuffers is only called from the EventLoop (eb4d317b9d64f3945a209804fec4c3fe695f4f9f) it should clear readInProgress and drain/release the queue. Otherwise if a read event is pending (doBeginRead) was called we may later call channelRead or channelReadComplete after we have closed the channel. Modifications: LocalChannel#releaseInboundBuffers should always clear/release the queue and set readInProgress to false Result: LocalChannel queue is more reliably cleaned up. --- .../src/main/java/io/netty/channel/local/LocalChannel.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/local/LocalChannel.java b/transport/src/main/java/io/netty/channel/local/LocalChannel.java index 980cc73f49..8b329e3e77 100644 --- a/transport/src/main/java/io/netty/channel/local/LocalChannel.java +++ b/transport/src/main/java/io/netty/channel/local/LocalChannel.java @@ -422,9 +422,8 @@ public class LocalChannel extends AbstractChannel { } private void releaseInboundBuffers() { - if (readInProgress) { - return; - } + assert eventLoop() == null || eventLoop().inEventLoop(); + readInProgress = false; Queue inboundBuffer = this.inboundBuffer; Object msg; while ((msg = inboundBuffer.poll()) != null) {