From 2addeae2db6db6fa5ac95b01907b5a5939b80abb Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Mon, 3 Aug 2015 15:41:03 -0700 Subject: [PATCH] NettyClientHandler should handle all exceptionCaught()s If NettyClientHandler doesn't then the exception will propagate to the end of the pipeline, get logged, and cause any open calls to hang. --- .../io/grpc/transport/netty/NettyClientHandler.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java b/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java index f07990d0d3..407782cea9 100644 --- a/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java +++ b/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java @@ -31,6 +31,7 @@ package io.grpc.transport.netty; +import static io.netty.handler.codec.http2.Http2CodecUtil.getEmbeddedHttp2Exception; import static io.netty.util.CharsetUtil.UTF_8; import com.google.common.annotations.VisibleForTesting; @@ -247,6 +248,17 @@ class NettyClientHandler extends Http2ConnectionHandler { } } + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + if (getEmbeddedHttp2Exception(cause) == null) { + // Kill the connection instead of propagating the exceptionCaught(). Http2ConnectionHandler + // only handles Http2Exceptions and propagates everything else. + goAwayStatus(Status.fromThrowable(cause)); + cause = new Http2Exception(Http2Error.INTERNAL_ERROR, null, cause); + } + super.exceptionCaught(ctx, cause); + } + @Override protected void onConnectionError(ChannelHandlerContext ctx, Throwable cause, Http2Exception http2Ex) {