Are you interested in providing a PR? @swrdlgc  @swrdlgc actually this can never happen as `deflate(...)` will return the number of bytes written to the output buffer which will be 0 if it was not writable. The good thing is because of this bug report I think I spotted a bug which is unrelated to the reported problem tho ;) thanks for replay, you are right, this can never happen.

Infinite loop in JdkZlibEncoder.deflate()
<pre>
private void deflate(ByteBuf out) {
    int numBytes;
    do {
        int writerIndex = out.writerIndex();
        numBytes = deflater.deflate(
                out.array(), out.arrayOffset() + writerIndex, out.writableBytes(), Deflater.SYNC_FLUSH);
        out.writerIndex(writerIndex + numBytes);
    } while (numBytes > 0);
}
</pre>
if out.writableBytes() is ZERO and numBytes>0, the function will never return!
codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
diff --git a/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java b/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
index f039fa66e84..276d7f86b0c 100644
--- a/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
+++ b/codec/src/main/java/io/netty/handler/codec/compression/JdkZlibEncoder.java
@@ -225,8 +225,18 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf uncompressed, ByteBuf o
         }
 
         deflater.setInput(inAry, offset, len);
-        while (!deflater.needsInput()) {
+        for (;;) {
             deflate(out);
+            if (deflater.needsInput()) {
+                // Consumed everything
+                break;
+            } else {
+                if (!out.isWritable()) {
+                    // We did not consume everything but the buffer is not writable anymore. Increase the capacity to
+                    // make more room.
+                    out.ensureWritable(out.writerIndex());
+                }
+            }
         }
     }
 
