mirror of https://github.com/grpc/grpc-java.git
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:
parent
849ed1b995
commit
2addeae2db
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
package io.grpc.transport.netty;
|
package io.grpc.transport.netty;
|
||||||
|
|
||||||
|
import static io.netty.handler.codec.http2.Http2CodecUtil.getEmbeddedHttp2Exception;
|
||||||
import static io.netty.util.CharsetUtil.UTF_8;
|
import static io.netty.util.CharsetUtil.UTF_8;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
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
|
@Override
|
||||||
protected void onConnectionError(ChannelHandlerContext ctx, Throwable cause,
|
protected void onConnectionError(ChannelHandlerContext ctx, Throwable cause,
|
||||||
Http2Exception http2Ex) {
|
Http2Exception http2Ex) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue