From 04a6c8395b9d1e0216589aaa10a607c704a99592 Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Thu, 4 Feb 2016 13:13:15 -0800 Subject: [PATCH] Remove deprecated call and TODO in Protocol negotiators --- .../java/io/grpc/netty/ProtocolNegotiator.java | 7 ++----- .../io/grpc/netty/ProtocolNegotiators.java | 18 ++++-------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/netty/src/main/java/io/grpc/netty/ProtocolNegotiator.java b/netty/src/main/java/io/grpc/netty/ProtocolNegotiator.java index 22b95e7b7a..15c5f07b96 100644 --- a/netty/src/main/java/io/grpc/netty/ProtocolNegotiator.java +++ b/netty/src/main/java/io/grpc/netty/ProtocolNegotiator.java @@ -32,7 +32,7 @@ package io.grpc.netty; import io.grpc.Internal; -import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelInboundHandler; import io.netty.handler.codec.http2.Http2ConnectionHandler; import io.netty.util.AsciiString; @@ -44,11 +44,8 @@ public interface ProtocolNegotiator { /** * The Netty handler to control the protocol negotiation. - * - *

TODO(carl-mastrangelo): Replace ChannelHandler with ChannelInboundHandler or - * ChannelOutboundHandler, since exceptionCaught is deprecated. */ - interface Handler extends ChannelHandler { + interface Handler extends ChannelInboundHandler { /** * The HTTP/2 scheme to be used when sending {@code HEADERS}. */ diff --git a/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java b/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java index 1f53160d0c..c69dfc11c5 100644 --- a/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java +++ b/netty/src/main/java/io/grpc/netty/ProtocolNegotiators.java @@ -89,30 +89,20 @@ public final class ProtocolNegotiators { return new ProtocolNegotiator() { @Override public Handler newHandler(final Http2ConnectionHandler handler) { - return new Handler() { + class PlaintextHandler extends ChannelDuplexHandler implements Handler { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { // Just replace this handler with the gRPC handler. ctx.pipeline().replace(this, null, handler); } - @Override - public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { - // Don't care. - } - - @Override - @Deprecated - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - // Should never happen. - ctx.fireExceptionCaught(cause); - } - @Override public AsciiString scheme() { return Utils.HTTP; } - }; + } + + return new PlaintextHandler(); } }; }