diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java index 9f61e6de826f..062b944563b5 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java @@ -573,15 +573,20 @@ public void forEachFlushedMessage(MessageProcessor processor) throws Exception { if (processor == null) { throw new NullPointerException("processor"); } + Entry entry = flushedEntry; - while (entry != null) { + if (entry == null) { + return; + } + + do { if (!entry.cancelled) { if (!processor.processMessage(entry.msg)) { return; } } entry = entry.next; - } + } while (entry != null && entry != unflushedEntry); } public interface MessageProcessor {