diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java index 22df18e08c..e98407e03a 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java @@ -151,13 +151,15 @@ public final class ChannelOutboundBuffer { } final int size = channel.calculateMessageSize(msg); - incrementPendingOutboundBytes(size); - unflushed[unflushedCount] = msg; unflushedPendingSizes[unflushedCount] = size; unflushedPromises[unflushedCount] = promise; unflushedTotals[unflushedCount] = total(msg); this.unflushedCount = unflushedCount + 1; + + // increment pending bytes after adding message to the unflushed arrays. + // See https://github.com/netty/netty/issues/1619 + incrementPendingOutboundBytes(size); } private static long total(Object msg) {