Repository: netty/netty
Issue: HTTP/2 Codec remove compressed from method signatures

**Motivation**
HTTP/2 Draft-13 removed the explicit per frame gzip compression support present in previous drafts.  The per frame compression concept was partially removed from the code base as part of updating to Draft-13.  The concept still exists in some classes and method signatures related to the outbound message flow code path.

**Modifications**
1. Removing the `compressed` member variable from the `io.netty.handler.codec.http2$Frame` class.
2. Removing the `compressed` boolean variable from method signatures which relate to Draft-12.

**Result**
Removal of legacy draft concepts from code base.


Issue comments:
@nmittler can you take care ?

Sure thing ... created PR #2701 

@Scottmitch1 FYI, I think you only need to follow the netty commit message rules for pull requests, not issues.  When I first looked at this I thought it was a PR :)

@nmittler - That makes sense because I also confused @normanmaurer by doing this on another issue.

Separate question.  Is there something that needs to be explicitly done to have the PR auto built by the build system and notifications sent by @trustin-notification?

@Scottmitch1 nope, it's all automatically done when you create the PR.

Nope... Every PR is picked up

> Am 23.07.2014 um 18:52 schrieb Scottmitch1 notifications@github.com:
> 
> @nmittler - That makes sense because I also confused @normanmaurer by doing this on another issue.
> 
> Separate question. Is there something that needs to be explicitly done to have the PR auto built by the build system and notifications sent by @trustin-notification?
> 
> —
> Reply to this email directly or view it on GitHub.

Fixed by  #2701 


Pull request review comments:

Patch that resolved the issue:
diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2ConnectionHandler.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2ConnectionHandler.java
index 92f43b5d65b..fba729c9f5a 100644
--- a/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2ConnectionHandler.java
+++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2ConnectionHandler.java
@@ -338,7 +338,7 @@ protected final int nextStreamId() {
 
     protected ChannelFuture writeData(final ChannelHandlerContext ctx,
             final ChannelPromise promise, int streamId, final ByteBuf data, int padding,
-            boolean endStream, boolean endSegment, boolean compressed) {
+            boolean endStream, boolean endSegment) {
         try {
             if (connection.isGoAway()) {
                 throw protocolError("Sending data after connection going away.");
@@ -349,7 +349,7 @@ protected ChannelFuture writeData(final ChannelHandlerContext ctx,
 
             // Hand control of the frame to the flow controller.
             outboundFlow.sendFlowControlled(streamId, data, padding, endStream, endSegment,
-                    compressed, new FlowControlWriter(ctx, data, promise));
+                    new FlowControlWriter(ctx, data, promise));
 
             return promise;
         } catch (Http2Exception e) {
@@ -1094,7 +1094,7 @@ private final class FlowControlWriter implements Http2OutboundFlowController.Fra
 
         @Override
         public void writeFrame(int streamId, ByteBuf data, int padding,
-                boolean endStream, boolean endSegment, boolean compressed) {
+                boolean endStream, boolean endSegment) {
             if (promise.isDone()) {
                 // Most likely the write already failed. Just release the
                 // buffer.
diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2OutboundFlowController.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2OutboundFlowController.java
index c7caa4e70f5..b731c5817aa 100644
--- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2OutboundFlowController.java
+++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2OutboundFlowController.java
@@ -149,10 +149,10 @@ public void updateOutboundWindowSize(int streamId, int delta) throws Http2Except
 
     @Override
     public void sendFlowControlled(int streamId, ByteBuf data, int padding, boolean endStream,
-            boolean endSegment, boolean compressed, FrameWriter frameWriter) throws Http2Exception {
+            boolean endSegment, FrameWriter frameWriter) throws Http2Exception {
         OutboundFlowState state = stateOrFail(streamId);
         OutboundFlowState.Frame frame =
-                state.newFrame(data, padding, endStream, endSegment, compressed, frameWriter);
+                state.newFrame(data, padding, endStream, endSegment, frameWriter);
 
         int dataLength = data.readableBytes();
         if (state.writableWindow() >= dataLength) {
@@ -442,8 +442,8 @@ int unallocatedPriorityBytes() {
          * Creates a new frame with the given values but does not add it to the pending queue.
          */
         Frame newFrame(ByteBuf data, int padding, boolean endStream, boolean endSegment,
-                boolean compressed, FrameWriter writer) {
-            return new Frame(data, padding, endStream, endSegment, compressed, writer);
+                FrameWriter writer) {
+            return new Frame(data, padding, endStream, endSegment, writer);
         }
 
         /**
@@ -530,17 +530,15 @@ private final class Frame {
             private final int padding;
             private final boolean endStream;
             private final boolean endSegment;
-            private final boolean compressed;
             private final FrameWriter writer;
             private boolean enqueued;
 
             Frame(ByteBuf data, int padding, boolean endStream, boolean endSegment,
-                    boolean compressed, FrameWriter writer) {
+                    FrameWriter writer) {
                 this.data = data;
                 this.padding = padding;
                 this.endStream = endStream;
                 this.endSegment = endSegment;
-                this.compressed = compressed;
                 this.writer = writer;
             }
 
@@ -580,7 +578,7 @@ void write() throws Http2Exception {
                 int dataLength = data.readableBytes();
                 connectionState().incrementStreamWindow(-dataLength);
                 incrementStreamWindow(-dataLength);
-                writer.writeFrame(stream.id(), data, padding, endStream, endSegment, compressed);
+                writer.writeFrame(stream.id(), data, padding, endStream, endSegment);
                 decrementPendingBytes(dataLength);
             }
 
@@ -606,7 +604,7 @@ void writeError(Http2Exception cause) {
             Frame split(int maxBytes) {
                 // TODO: Should padding be included in the chunks or only the last frame?
                 maxBytes = min(maxBytes, data.readableBytes());
-                Frame frame = new Frame(data.readSlice(maxBytes).retain(), 0, false, false, compressed, writer);
+                Frame frame = new Frame(data.readSlice(maxBytes).retain(), 0, false, false, writer);
                 decrementPendingBytes(maxBytes);
                 return frame;
             }
diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingHttp2ConnectionHandler.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingHttp2ConnectionHandler.java
index 433214c47af..a66f4b797ae 100644
--- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingHttp2ConnectionHandler.java
+++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DelegatingHttp2ConnectionHandler.java
@@ -53,9 +53,8 @@ public DelegatingHttp2ConnectionHandler(Http2Connection connection, Http2FrameOb
 
     @Override
     public ChannelFuture writeData(ChannelHandlerContext ctx, ChannelPromise promise, int streamId,
-            ByteBuf data, int padding, boolean endStream, boolean endSegment, boolean compressed) {
-        return super.writeData(ctx, promise, streamId, data, padding, endStream, endSegment,
-                compressed);
+            ByteBuf data, int padding, boolean endStream, boolean endSegment) {
+        return super.writeData(ctx, promise, streamId, data, padding, endStream, endSegment);
     }
 
     @Override
diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2OutboundFlowController.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2OutboundFlowController.java
index 57f3cc70c9c..4573e1eb0af 100644
--- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2OutboundFlowController.java
+++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2OutboundFlowController.java
@@ -31,7 +31,7 @@ interface FrameWriter {
          * Writes a single data frame to the remote endpoint.
          */
         void writeFrame(int streamId, ByteBuf data, int padding, boolean endStream,
-                boolean endSegment, boolean compressed);
+                boolean endSegment);
 
         /**
          * Called if an error occurred before the write could take place. Sets the failure on the
@@ -80,10 +80,9 @@ void writeFrame(int streamId, ByteBuf data, int padding, boolean endStream,
      * @param padding the number of bytes of padding to be added to the frame.
      * @param endStream indicates whether this frames is to be the last sent on this stream.
      * @param endSegment indicates whether this is to be the last frame in the segment.
-     * @param compressed whether the data is compressed using gzip compression.
      * @param frameWriter peforms to the write of the frame to the remote endpoint.
      * @throws Http2Exception thrown if a protocol-related error occurred.
      */
     void sendFlowControlled(int streamId, ByteBuf data, int padding, boolean endStream,
-            boolean endSegment, boolean compressed, FrameWriter frameWriter) throws Http2Exception;
+            boolean endSegment, FrameWriter frameWriter) throws Http2Exception;
 }
diff --git a/example/src/main/java/io/netty/example/http2/server/HelloWorldHttp2Handler.java b/example/src/main/java/io/netty/example/http2/server/HelloWorldHttp2Handler.java
index 3f60cb6f517..0f3aa522045 100644
--- a/example/src/main/java/io/netty/example/http2/server/HelloWorldHttp2Handler.java
+++ b/example/src/main/java/io/netty/example/http2/server/HelloWorldHttp2Handler.java
@@ -112,6 +112,6 @@ private void sendResponse(ChannelHandlerContext ctx, int streamId, ByteBuf paylo
         Http2Headers headers = DefaultHttp2Headers.newBuilder().status("200").build();
         writeHeaders(ctx(), ctx().newPromise(), streamId, headers, 0, false, false);
 
-        writeData(ctx(), ctx().newPromise(), streamId, payload, 0, true, true, false);
+        writeData(ctx(), ctx().newPromise(), streamId, payload, 0, true, true);
     }
 }


Test patch:
diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2OutboundFlowControllerTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2OutboundFlowControllerTest.java
index 5221fa99520..e96c372ee7c 100644
--- a/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2OutboundFlowControllerTest.java
+++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2OutboundFlowControllerTest.java
@@ -542,22 +542,21 @@ public void samePriorityShouldWriteEqualData() throws Http2Exception {
     }
 
     private void send(int streamId, ByteBuf data) throws Http2Exception {
-        controller.sendFlowControlled(streamId, data, 0, false, false, false, frameWriter);
+        controller.sendFlowControlled(streamId, data, 0, false, false, frameWriter);
     }
 
     private void verifyWrite(int streamId, ByteBuf data) {
-        verify(frameWriter).writeFrame(eq(streamId), eq(data), eq(0), eq(false), eq(false),
-                eq(false));
+        verify(frameWriter).writeFrame(eq(streamId), eq(data), eq(0), eq(false), eq(false));
     }
 
     private void verifyNoWrite(int streamId) {
         verify(frameWriter, never()).writeFrame(eq(streamId), any(ByteBuf.class), anyInt(),
-                anyBoolean(), anyBoolean(), anyBoolean());
+                anyBoolean(), anyBoolean());
     }
 
     private void captureWrite(int streamId, ArgumentCaptor<ByteBuf> captor, boolean endStream) {
         verify(frameWriter).writeFrame(eq(streamId), captor.capture(), eq(0), eq(endStream),
-                eq(false), eq(false));
+                eq(false));
     }
 
     private void setPriority(int stream, int parent, int weight, boolean exclusive)
diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/DelegatingHttp2ConnectionHandlerTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/DelegatingHttp2ConnectionHandlerTest.java
index b92ba8ade9d..920b4040436 100644
--- a/codec-http2/src/test/java/io/netty/handler/codec/http2/DelegatingHttp2ConnectionHandlerTest.java
+++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/DelegatingHttp2ConnectionHandlerTest.java
@@ -442,15 +442,15 @@ public void goAwayShouldReadShouldUpdateConnectionState() throws Exception {
     @Test
     public void dataWriteAfterGoAwayShouldFail() throws Exception {
         when(connection.isGoAway()).thenReturn(true);
-        ChannelFuture future = handler.writeData(ctx, promise, STREAM_ID, dummyData(), 0, false, false, false);
+        ChannelFuture future = handler.writeData(ctx, promise, STREAM_ID, dummyData(), 0, false, false);
         assertTrue(future.awaitUninterruptibly().cause() instanceof Http2Exception);
     }
 
     @Test
     public void dataWriteShouldSucceed() throws Exception {
-        handler.writeData(ctx, promise, STREAM_ID, dummyData(), 0, false, false, false);
+        handler.writeData(ctx, promise, STREAM_ID, dummyData(), 0, false, false);
         verify(outboundFlow).sendFlowControlled(eq(STREAM_ID), eq(dummyData()), eq(0), eq(false),
-                eq(false), eq(false), any(Http2OutboundFlowController.FrameWriter.class));
+                eq(false), any(Http2OutboundFlowController.FrameWriter.class));
     }
 
     @Test
diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java
index 7ffd9e5ef99..098495da8d0 100644
--- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java
+++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionRoundtripTest.java
@@ -121,7 +121,7 @@ public void run() {
                     http2Client.writePing(ctx(), newPromise(), Unpooled.copiedBuffer(pingMsg.getBytes()));
                     http2Client.writeData(
                             ctx(), newPromise(), nextStream,
-                            Unpooled.copiedBuffer(text.getBytes()), 0, true, true, false);
+                            Unpooled.copiedBuffer(text.getBytes()), 0, true, true);
                 }
             }
         });