From 22c13271d142dee6a218c5e7742cfba2fcc128c4 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sat, 5 Apr 2014 16:17:42 +0200 Subject: [PATCH] First round of cleanup codec-http2 --- .../codec/http2/draft10/Http2Error.java | 4 +-- .../connection/DefaultHttp2Connection.java | 32 +++++++++---------- .../DefaultInboundFlowController.java | 4 +-- .../DefaultOutboundFlowController.java | 8 ++--- .../connection/Http2ConnectionHandler.java | 7 ++-- .../http2/draft10/connection/Http2Stream.java | 2 +- .../draft10/frame/DefaultHttp2DataFrame.java | 8 ++--- .../frame/DefaultHttp2GoAwayFrame.java | 4 +-- .../frame/DefaultHttp2HeadersFrame.java | 14 ++++---- .../draft10/frame/DefaultHttp2PingFrame.java | 2 +- .../frame/DefaultHttp2PriorityFrame.java | 4 +-- .../frame/DefaultHttp2PushPromiseFrame.java | 8 ++--- .../frame/DefaultHttp2RstStreamFrame.java | 4 +-- .../frame/DefaultHttp2SettingsFrame.java | 10 +++--- .../frame/DefaultHttp2WindowUpdateFrame.java | 4 +-- .../draft10/frame/Http2FrameCodecUtil.java | 6 ++-- .../http2/draft10/frame/Http2FrameHeader.java | 8 ++--- .../draft10/frame/Http2SettingsFrame.java | 2 -- .../decoder/AbstractHeadersUnmarshaller.java | 2 +- .../decoder/DefaultHttp2HeadersDecoder.java | 2 +- .../decoder/Http2DataFrameUnmarshaller.java | 1 + .../frame/decoder/Http2FrameDecoder.java | 4 +-- .../decoder/Http2GoAwayFrameUnmarshaller.java | 1 + .../Http2HeadersFrameUnmarshaller.java | 1 + .../decoder/Http2PingFrameUnmarshaller.java | 1 + .../Http2PriorityFrameUnmarshaller.java | 1 + .../Http2PushPromiseFrameUnmarshaller.java | 1 + .../Http2RstStreamFrameUnmarshaller.java | 1 + .../Http2SettingsFrameUnmarshaller.java | 1 + .../Http2StandardFrameUnmarshaller.java | 15 +++++++-- .../encoder/DefaultHttp2HeadersEncoder.java | 2 +- .../encoder/Http2DataFrameMarshaller.java | 2 +- .../encoder/Http2HeadersFrameMarshaller.java | 2 +- .../Http2PushPromiseFrameMarshaller.java | 2 +- .../DefaultInboundFlowControllerTest.java | 4 +-- .../DefaultOutboundFlowControllerTest.java | 2 +- .../frame/Http2FrameRoundtripTest.java | 4 +-- 37 files changed, 97 insertions(+), 83 deletions(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/Http2Error.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/Http2Error.java index bbfdf2bf02..9c4a3a085c 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/Http2Error.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/Http2Error.java @@ -35,11 +35,11 @@ public enum Http2Error { private final int code; - private Http2Error(int code) { + Http2Error(int code) { this.code = code; } public int getCode() { - return this.code; + return code; } } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultHttp2Connection.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultHttp2Connection.java index 86be3241db..94af51acb4 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultHttp2Connection.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultHttp2Connection.java @@ -56,8 +56,8 @@ public class DefaultHttp2Connection implements Http2Connection { private ChannelFutureListener closeListener; public DefaultHttp2Connection(boolean server) { - this.localEndpoint = new DefaultEndpoint(server); - this.remoteEndpoint = new DefaultEndpoint(!server); + localEndpoint = new DefaultEndpoint(server); + remoteEndpoint = new DefaultEndpoint(!server); } @Override @@ -158,18 +158,6 @@ public class DefaultHttp2Connection implements Http2Connection { return closeListener; } - private void notifyStreamClosed(int id) { - for (Listener listener : listeners) { - listener.streamClosed(id); - } - } - - private void notifyStreamCreated(int id) { - for (Listener listener : listeners) { - listener.streamCreated(id); - } - } - /** * Simple stream implementation. Streams can be compared to each other by priority. */ @@ -180,7 +168,7 @@ public class DefaultHttp2Connection implements Http2Connection { public DefaultStream(int id) { this.id = id; - this.priority = DEFAULT_STREAM_PRIORITY; + priority = DEFAULT_STREAM_PRIORITY; } @Override @@ -331,6 +319,12 @@ public class DefaultHttp2Connection implements Http2Connection { return false; } } + + private void notifyStreamClosed(int id) { + for (Listener listener : listeners) { + listener.streamClosed(id); + } + } } /** @@ -406,7 +400,7 @@ public class DefaultHttp2Connection implements Http2Connection { @Override public void setPushToAllowed(boolean allow) { - this.pushToAllowed = allow; + pushToAllowed = allow; } @Override @@ -453,5 +447,11 @@ public class DefaultHttp2Connection implements Http2Connection { private boolean isLocal() { return this == localEndpoint; } + + private void notifyStreamCreated(int id) { + for (Listener listener : listeners) { + listener.streamCreated(id); + } + } } } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultInboundFlowController.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultInboundFlowController.java index 9a891387a0..79466074d9 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultInboundFlowController.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultInboundFlowController.java @@ -35,7 +35,7 @@ import com.google.common.collect.Maps; public class DefaultInboundFlowController implements InboundFlowController { private int initialWindowSize = DEFAULT_FLOW_CONTROL_WINDOW_SIZE; - private StreamWindow connectionWindow = new StreamWindow(CONNECTION_STREAM_ID); + private final StreamWindow connectionWindow = new StreamWindow(CONNECTION_STREAM_ID); private final Map streamWindows = Maps.newHashMap(); public DefaultInboundFlowController(Http2Connection connection) { @@ -134,7 +134,7 @@ public class DefaultInboundFlowController implements InboundFlowController { public StreamWindow(int streamId) { this.streamId = streamId; - this.windowSize = initialWindowSize; + windowSize = initialWindowSize; } public int getSize() { diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultOutboundFlowController.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultOutboundFlowController.java index c9ea359e72..5d458f1be0 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultOutboundFlowController.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/DefaultOutboundFlowController.java @@ -79,7 +79,7 @@ public class DefaultOutboundFlowController implements OutboundFlowController { @Override public void updateOutboundWindowSize(int streamId, int delta) throws Http2Exception { - StreamState streamWindow = null; + StreamState streamWindow; if (streamId == CONNECTION_STREAM_ID) { // Update the connection window and write any pending frames for all streams. addAndGetConnectionWindowSize(delta); @@ -146,7 +146,7 @@ public class DefaultOutboundFlowController implements OutboundFlowController { * bytes. The reader index on the input frame is then advanced by the number of bytes. The * returned frame will not have end-of-stream set. */ - private Http2DataFrame readPartialFrame(Http2DataFrame frame, int numBytes) { + private static Http2DataFrame readPartialFrame(Http2DataFrame frame, int numBytes) { return new DefaultHttp2DataFrame.Builder().setStreamId(frame.getStreamId()) .setContent(frame.content().readSlice(numBytes).retain()).build(); } @@ -154,7 +154,7 @@ public class DefaultOutboundFlowController implements OutboundFlowController { /** * Indicates whether applying the delta to the given value will cause an integer overflow. */ - private boolean isIntegerOverflow(int previousValue, int delta) { + private static boolean isIntegerOverflow(int previousValue, int delta) { return delta > 0 && (Integer.MAX_VALUE - delta) < previousValue; } @@ -263,7 +263,7 @@ public class DefaultOutboundFlowController implements OutboundFlowController { /** * Pending write for a single data frame. */ - private class PendingWrite { + private static class PendingWrite { private final Http2DataFrame frame; private final FrameWriter writer; diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/Http2ConnectionHandler.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/Http2ConnectionHandler.java index 86d8ee1852..1d310593bb 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/Http2ConnectionHandler.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/Http2ConnectionHandler.java @@ -157,7 +157,6 @@ public class Http2ConnectionHandler extends ChannelHandlerAdapter { handleOutboundSettings(ctx, (Http2SettingsFrame) msg, promise); } else { ctx.write(msg, promise); - return; } } catch (Throwable e) { @@ -328,7 +327,7 @@ public class Http2ConnectionHandler extends ChannelHandlerAdapter { ctx.fireChannelRead(frame); } - private void handleInboundPing(ChannelHandlerContext ctx, Http2PingFrame frame) { + private static void handleInboundPing(ChannelHandlerContext ctx, Http2PingFrame frame) { if (frame.isAck()) { // The remote enpoint is responding to an Ack that we sent. ctx.fireChannelRead(frame); @@ -510,13 +509,13 @@ public class Http2ConnectionHandler extends ChannelHandlerAdapter { ctx.writeAndFlush(frame, promise); } - private void handleOutboundGoAway() throws Http2Exception { + private static void handleOutboundGoAway() throws Http2Exception { // Why is this being sent? Intercept it and fail the write. // Should have sent a CLOSE ChannelStateEvent throw format(PROTOCOL_ERROR, "Another handler attempted to send GoAway."); } - private void handleOutboundWindowUpdate() throws Http2Exception { + private static void handleOutboundWindowUpdate() throws Http2Exception { // Why is this being sent? Intercept it and fail the write. throw format(PROTOCOL_ERROR, "Another handler attempted to send window update."); } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/Http2Stream.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/Http2Stream.java index 95a6a755ba..7fe5f68e9c 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/Http2Stream.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/connection/Http2Stream.java @@ -29,7 +29,7 @@ public interface Http2Stream extends Comparable { * The allowed states of an HTTP2 stream. */ enum State { - IDLE, RESERVED_LOCAL, RESERVED_REMOTE, OPEN, HALF_CLOSED_LOCAL, HALF_CLOSED_REMOTE, CLOSED; + IDLE, RESERVED_LOCAL, RESERVED_REMOTE, OPEN, HALF_CLOSED_LOCAL, HALF_CLOSED_REMOTE, CLOSED } /** diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2DataFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2DataFrame.java index 135c2ff91f..561b910ce4 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2DataFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2DataFrame.java @@ -33,9 +33,9 @@ public final class DefaultHttp2DataFrame extends DefaultByteBufHolder implements private DefaultHttp2DataFrame(Builder builder) { super(builder.content); - this.streamId = builder.streamId; - this.endOfStream = builder.endOfStream; - this.paddingLength = builder.paddingLength; + streamId = builder.streamId; + endOfStream = builder.endOfStream; + paddingLength = builder.paddingLength; } @Override @@ -180,7 +180,7 @@ public final class DefaultHttp2DataFrame extends DefaultByteBufHolder implements return new DefaultHttp2DataFrame(this); } - private void verifyLength(int paddingLength, ByteBuf data) { + private static void verifyLength(int paddingLength, ByteBuf data) { int maxLength = MAX_FRAME_PAYLOAD_LENGTH; maxLength -= paddingLength; if (data.readableBytes() > maxLength) { diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2GoAwayFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2GoAwayFrame.java index 8ecc284d58..1572a21a2a 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2GoAwayFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2GoAwayFrame.java @@ -32,8 +32,8 @@ public final class DefaultHttp2GoAwayFrame extends DefaultByteBufHolder implemen private DefaultHttp2GoAwayFrame(Builder builder) { super(builder.debugData); - this.lastStreamId = builder.lastStreamId; - this.errorCode = builder.errorCode; + lastStreamId = builder.lastStreamId; + errorCode = builder.errorCode; } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2HeadersFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2HeadersFrame.java index aeaf1ef7e6..f4133ae810 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2HeadersFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2HeadersFrame.java @@ -27,10 +27,10 @@ public final class DefaultHttp2HeadersFrame implements Http2HeadersFrame { private final Http2Headers headers; private DefaultHttp2HeadersFrame(Builder builder) { - this.streamId = builder.streamId; - this.priority = builder.priority; - this.headers = builder.headersBuilder.build(); - this.endOfStream = builder.endOfStream; + streamId = builder.streamId; + priority = builder.priority; + headers = builder.headersBuilder.build(); + endOfStream = builder.endOfStream; } @Override @@ -98,13 +98,13 @@ public final class DefaultHttp2HeadersFrame implements Http2HeadersFrame { @Override public String toString() { return "DefaultHttp2HeadersFrame [streamId=" + streamId + ", priority=" + priority - + ", endOfStream=" + endOfStream + ", headers=" + headers + "]"; + + ", endOfStream=" + endOfStream + ", headers=" + headers + ']'; } public static class Builder { private int streamId; private int priority = DEFAULT_STREAM_PRIORITY; - private Http2Headers.Builder headersBuilder = new Http2Headers.Builder(); + private final Http2Headers.Builder headersBuilder = new Http2Headers.Builder(); private boolean endOfStream; public Builder setStreamId(int streamId) { @@ -133,7 +133,7 @@ public final class DefaultHttp2HeadersFrame implements Http2HeadersFrame { } public Builder setHeaders(Http2Headers headers) { - this.headersBuilder.addHeaders(headers); + headersBuilder.addHeaders(headers); return this; } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PingFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PingFrame.java index 5c3a065749..bff0e49037 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PingFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PingFrame.java @@ -29,7 +29,7 @@ public final class DefaultHttp2PingFrame extends DefaultByteBufHolder implements private DefaultHttp2PingFrame(Builder builder) { super(builder.data); - this.ack = builder.ack; + ack = builder.ack; } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PriorityFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PriorityFrame.java index 28bd8c3e1d..53d643c019 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PriorityFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PriorityFrame.java @@ -24,8 +24,8 @@ public final class DefaultHttp2PriorityFrame implements Http2PriorityFrame { private final int priority; private DefaultHttp2PriorityFrame(Builder builder) { - this.streamId = builder.streamId; - this.priority = builder.priority; + streamId = builder.streamId; + priority = builder.priority; } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PushPromiseFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PushPromiseFrame.java index 43ec2c2339..c498d46577 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PushPromiseFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2PushPromiseFrame.java @@ -24,9 +24,9 @@ public final class DefaultHttp2PushPromiseFrame implements Http2PushPromiseFrame private final Http2Headers headers; private DefaultHttp2PushPromiseFrame(Builder builder) { - this.streamId = builder.streamId; - this.promisedStreamId = builder.promisedStreamId; - this.headers = builder.headers; + streamId = builder.streamId; + promisedStreamId = builder.promisedStreamId; + headers = builder.headers; } @Override @@ -90,7 +90,7 @@ public final class DefaultHttp2PushPromiseFrame implements Http2PushPromiseFrame @Override public String toString() { return "DefaultHttp2PushPromiseFrame [streamId=" + streamId + ", promisedStreamId=" - + promisedStreamId + ", headers=" + headers + "]"; + + promisedStreamId + ", headers=" + headers + ']'; } public static class Builder { diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2RstStreamFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2RstStreamFrame.java index 8e17234e8d..63ff05cdb6 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2RstStreamFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2RstStreamFrame.java @@ -25,8 +25,8 @@ public final class DefaultHttp2RstStreamFrame implements Http2RstStreamFrame { private final long errorCode; private DefaultHttp2RstStreamFrame(Builder builder) { - this.streamId = builder.streamId; - this.errorCode = builder.errorCode; + streamId = builder.streamId; + errorCode = builder.errorCode; } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2SettingsFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2SettingsFrame.java index ebfd84e41e..9e9d3bc68d 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2SettingsFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2SettingsFrame.java @@ -27,11 +27,11 @@ public final class DefaultHttp2SettingsFrame implements Http2SettingsFrame { private final Integer initialWindowSize; private DefaultHttp2SettingsFrame(Builder builder) { - this.ack = builder.ack; - this.headerTableSize = builder.headerTableSize; - this.pushEnabled = builder.pushEnabled; - this.maxConcurrentStreams = builder.maxConcurrentStreams; - this.initialWindowSize = builder.initialWindowSize; + ack = builder.ack; + headerTableSize = builder.headerTableSize; + pushEnabled = builder.pushEnabled; + maxConcurrentStreams = builder.maxConcurrentStreams; + initialWindowSize = builder.initialWindowSize; } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2WindowUpdateFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2WindowUpdateFrame.java index 7983e6196f..4451e11765 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2WindowUpdateFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/DefaultHttp2WindowUpdateFrame.java @@ -24,8 +24,8 @@ public final class DefaultHttp2WindowUpdateFrame implements Http2WindowUpdateFra private final int windowSizeIncrement; private DefaultHttp2WindowUpdateFrame(Builder builder) { - this.streamId = builder.streamId; - this.windowSizeIncrement = builder.windowSizeIncrement; + streamId = builder.streamId; + windowSizeIncrement = builder.windowSizeIncrement; } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2FrameCodecUtil.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2FrameCodecUtil.java index 393402b721..8a375e4844 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2FrameCodecUtil.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2FrameCodecUtil.java @@ -62,7 +62,7 @@ public final class Http2FrameCodecUtil { */ public static int readUnsignedInt(ByteBuf buf) { int offset = buf.readerIndex(); - int value = (buf.getByte(offset + 0) & 0x7F) << 24 | (buf.getByte(offset + 1) & 0xFF) << 16 + int value = (buf.getByte(offset) & 0x7F) << 24 | (buf.getByte(offset + 1) & 0xFF) << 16 | (buf.getByte(offset + 2) & 0xFF) << 8 | buf.getByte(offset + 3) & 0xFF; buf.skipBytes(4); return value; @@ -98,10 +98,10 @@ public final class Http2FrameCodecUtil { */ public static short setPaddingFlags(short flags, int paddingLength) { if (paddingLength > 255) { - flags |= Http2FrameCodecUtil.FLAG_PAD_HIGH; + flags |= FLAG_PAD_HIGH; } if (paddingLength > 0) { - flags |= Http2FrameCodecUtil.FLAG_PAD_LOW; + flags |= FLAG_PAD_LOW; } return flags; } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2FrameHeader.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2FrameHeader.java index 265d2190ba..750bdb531a 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2FrameHeader.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2FrameHeader.java @@ -26,10 +26,10 @@ public final class Http2FrameHeader { private final int streamId; private Http2FrameHeader(Builder builder) { - this.payloadLength = builder.payloadLength; - this.type = builder.type; - this.flags = builder.flags; - this.streamId = builder.streamId; + payloadLength = builder.payloadLength; + type = builder.type; + flags = builder.flags; + streamId = builder.streamId; } public int getPayloadLength() { diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2SettingsFrame.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2SettingsFrame.java index 8a891ab5f2..e16232a8e1 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2SettingsFrame.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/Http2SettingsFrame.java @@ -43,8 +43,6 @@ public interface Http2SettingsFrame extends Http2Frame { /** * Gets the sender's initial flow control window in bytes, or {@code null} if not set. - * - * @return */ Integer getInitialWindowSize(); } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/AbstractHeadersUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/AbstractHeadersUnmarshaller.java index a1fce43fb9..613253fc63 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/AbstractHeadersUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/AbstractHeadersUnmarshaller.java @@ -32,7 +32,7 @@ public abstract class AbstractHeadersUnmarshaller extends AbstractHttp2FrameUnma /** * A builder for a headers/push_promise frame. */ - protected abstract class FrameBuilder { + protected abstract static class FrameBuilder { protected ByteBuf headerBlock; abstract int getStreamId(); diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/DefaultHttp2HeadersDecoder.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/DefaultHttp2HeadersDecoder.java index ac494c3560..d231296945 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/DefaultHttp2HeadersDecoder.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/DefaultHttp2HeadersDecoder.java @@ -34,7 +34,7 @@ public class DefaultHttp2HeadersDecoder implements Http2HeadersDecoder { private final Decoder decoder; public DefaultHttp2HeadersDecoder() { - this.decoder = new Decoder(DEFAULT_MAX_HEADER_SIZE, DEFAULT_HEADER_TABLE_SIZE); + decoder = new Decoder(DEFAULT_MAX_HEADER_SIZE, DEFAULT_HEADER_TABLE_SIZE); } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2DataFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2DataFrameUnmarshaller.java index c6f19efc21..4217c73e32 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2DataFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2DataFrameUnmarshaller.java @@ -24,6 +24,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.handler.codec.http2.draft10.Http2Exception; import io.netty.handler.codec.http2.draft10.frame.DefaultHttp2DataFrame; +import io.netty.handler.codec.http2.draft10.frame.Http2DataFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Flags; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2FrameDecoder.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2FrameDecoder.java index 9e97af3faa..87f1d35302 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2FrameDecoder.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2FrameDecoder.java @@ -45,8 +45,8 @@ public class Http2FrameDecoder extends ByteToMessageDecoder { ERROR } + private final Http2FrameUnmarshaller frameUnmarshaller; private State state; - private Http2FrameUnmarshaller frameUnmarshaller; private int payloadLength; public Http2FrameDecoder() { @@ -55,7 +55,7 @@ public class Http2FrameDecoder extends ByteToMessageDecoder { public Http2FrameDecoder(Http2FrameUnmarshaller frameUnmarshaller) { this.frameUnmarshaller = frameUnmarshaller; - this.state = State.FRAME_HEADER; + state = State.FRAME_HEADER; } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2GoAwayFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2GoAwayFrameUnmarshaller.java index 61159d1499..686d20f129 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2GoAwayFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2GoAwayFrameUnmarshaller.java @@ -26,6 +26,7 @@ import io.netty.handler.codec.http2.draft10.Http2Exception; import io.netty.handler.codec.http2.draft10.frame.DefaultHttp2GoAwayFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; +import io.netty.handler.codec.http2.draft10.frame.Http2GoAwayFrame; /** * An unmarshaller for {@link Http2GoAwayFrame} instances. The buffer contained in the frames is a diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2HeadersFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2HeadersFrameUnmarshaller.java index 4bbb48d9c6..f17c1a2c03 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2HeadersFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2HeadersFrameUnmarshaller.java @@ -29,6 +29,7 @@ import io.netty.handler.codec.http2.draft10.frame.DefaultHttp2HeadersFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Flags; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; +import io.netty.handler.codec.http2.draft10.frame.Http2HeadersFrame; import com.google.common.base.Preconditions; diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PingFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PingFrameUnmarshaller.java index 34ccdc2cf1..8315c154f8 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PingFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PingFrameUnmarshaller.java @@ -25,6 +25,7 @@ import io.netty.handler.codec.http2.draft10.Http2Exception; import io.netty.handler.codec.http2.draft10.frame.DefaultHttp2PingFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; +import io.netty.handler.codec.http2.draft10.frame.Http2PingFrame; /** * An unmarshaller for {@link Http2PingFrame} instances. The buffer contained in the frames is a diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PriorityFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PriorityFrameUnmarshaller.java index ed271175d6..949287c78f 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PriorityFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PriorityFrameUnmarshaller.java @@ -26,6 +26,7 @@ import io.netty.handler.codec.http2.draft10.Http2Exception; import io.netty.handler.codec.http2.draft10.frame.DefaultHttp2PriorityFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; +import io.netty.handler.codec.http2.draft10.frame.Http2PriorityFrame; /** * An unmarshaller for {@link Http2PriorityFrame} instances. diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PushPromiseFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PushPromiseFrameUnmarshaller.java index 46829df7ad..5c13fec8cf 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PushPromiseFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2PushPromiseFrameUnmarshaller.java @@ -28,6 +28,7 @@ import io.netty.handler.codec.http2.draft10.frame.DefaultHttp2PushPromiseFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Flags; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; +import io.netty.handler.codec.http2.draft10.frame.Http2PushPromiseFrame; import com.google.common.base.Preconditions; diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2RstStreamFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2RstStreamFrameUnmarshaller.java index 9b4f965a10..d2d0e0509b 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2RstStreamFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2RstStreamFrameUnmarshaller.java @@ -25,6 +25,7 @@ import io.netty.handler.codec.http2.draft10.Http2Exception; import io.netty.handler.codec.http2.draft10.frame.DefaultHttp2RstStreamFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; +import io.netty.handler.codec.http2.draft10.frame.Http2RstStreamFrame; /** * An unmarshaller for {@link Http2RstStreamFrame} instances. diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2SettingsFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2SettingsFrameUnmarshaller.java index e2bf0b8a6f..f331a90095 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2SettingsFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2SettingsFrameUnmarshaller.java @@ -29,6 +29,7 @@ import io.netty.handler.codec.http2.draft10.Http2Exception; import io.netty.handler.codec.http2.draft10.frame.DefaultHttp2SettingsFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; +import io.netty.handler.codec.http2.draft10.frame.Http2SettingsFrame; /** * An unmarshaller for {@link Http2SettingsFrame} instances. diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2StandardFrameUnmarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2StandardFrameUnmarshaller.java index 20a3b01db1..c835592278 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2StandardFrameUnmarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/decoder/Http2StandardFrameUnmarshaller.java @@ -30,8 +30,17 @@ import static io.netty.handler.codec.http2.draft10.frame.Http2FrameCodecUtil.FRA import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.handler.codec.http2.draft10.Http2Exception; +import io.netty.handler.codec.http2.draft10.frame.Http2DataFrame; import io.netty.handler.codec.http2.draft10.frame.Http2Frame; import io.netty.handler.codec.http2.draft10.frame.Http2FrameHeader; +import io.netty.handler.codec.http2.draft10.frame.Http2GoAwayFrame; +import io.netty.handler.codec.http2.draft10.frame.Http2HeadersFrame; +import io.netty.handler.codec.http2.draft10.frame.Http2PingFrame; +import io.netty.handler.codec.http2.draft10.frame.Http2PriorityFrame; +import io.netty.handler.codec.http2.draft10.frame.Http2PushPromiseFrame; +import io.netty.handler.codec.http2.draft10.frame.Http2RstStreamFrame; +import io.netty.handler.codec.http2.draft10.frame.Http2SettingsFrame; +import io.netty.handler.codec.http2.draft10.frame.Http2WindowUpdateFrame; /** * A composite {@link Http2FrameUnmarshaller} that supports all frames identified by the HTTP2 spec. @@ -68,16 +77,16 @@ public class Http2StandardFrameUnmarshaller implements Http2FrameUnmarshaller { unmarshallers[FRAME_TYPE_GO_AWAY] = new Http2GoAwayFrameUnmarshaller(); unmarshallers[FRAME_TYPE_WINDOW_UPDATE] = new Http2WindowUpdateFrameUnmarshaller(); unmarshallers[FRAME_TYPE_CONTINUATION] = new Http2FrameUnmarshaller() { - private String msg = "Received continuation without headers or push_promise"; + private static final String MSG = "Received continuation without headers or push_promise"; @Override public Http2FrameUnmarshaller unmarshall(Http2FrameHeader header) throws Http2Exception { - throw protocolError(msg); + throw protocolError(MSG); } @Override public Http2Frame from(ByteBuf payload, ByteBufAllocator alloc) throws Http2Exception { - throw protocolError(msg); + throw protocolError(MSG); } }; } diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/encoder/DefaultHttp2HeadersEncoder.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/encoder/DefaultHttp2HeadersEncoder.java index b4cf30c7b0..4331c16475 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/encoder/DefaultHttp2HeadersEncoder.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/encoder/DefaultHttp2HeadersEncoder.java @@ -37,7 +37,7 @@ public class DefaultHttp2HeadersEncoder implements Http2HeadersEncoder { private final Encoder encoder; public DefaultHttp2HeadersEncoder() { - this.encoder = new Encoder(DEFAULT_HEADER_TABLE_SIZE); + encoder = new Encoder(DEFAULT_HEADER_TABLE_SIZE); } @Override diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/encoder/Http2DataFrameMarshaller.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/encoder/Http2DataFrameMarshaller.java index 18c5c53535..c9254533f1 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/encoder/Http2DataFrameMarshaller.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/draft10/frame/encoder/Http2DataFrameMarshaller.java @@ -56,7 +56,7 @@ public class Http2DataFrameMarshaller extends AbstractHttp2FrameMarshaller