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.
This commit is contained in:
Eric Anderson 2015-08-03 15:41:03 -07:00
parent 849ed1b995
commit 2addeae2db
1 changed files with 12 additions and 0 deletions

View File

@ -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) {