From d8d8ebd78355c7292b746a44d719b768d87ba61b Mon Sep 17 00:00:00 2001 From: nmittler Date: Wed, 6 May 2015 14:31:43 -0700 Subject: [PATCH] Adding logging to NettyClientHandler. --- .../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 9807846792..a2708b76a6 100644 --- a/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java +++ b/netty/src/main/java/io/grpc/transport/netty/NettyClientHandler.java @@ -35,6 +35,8 @@ import static io.netty.util.CharsetUtil.UTF_8; import com.google.common.base.Preconditions; +import com.sun.istack.internal.logging.Logger; + import io.grpc.Metadata; import io.grpc.Status; import io.grpc.transport.HttpUtil; @@ -63,6 +65,7 @@ import javax.annotation.Nullable; * the context of the Netty Channel thread. */ class NettyClientHandler extends Http2ConnectionHandler { + private static final Logger logger = Logger.getLogger(NettyClientHandler.class); private final Http2Connection.PropertyKey streamKey; private int connectionWindowSize; @@ -186,12 +189,19 @@ class NettyClientHandler extends Http2ConnectionHandler { stream.transportReportStatus(Status.UNKNOWN, false, new Metadata.Trailers()); } + @Override + public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { + logger.fine("Network channel being closed by the application."); + super.close(ctx, promise); + } + /** * Handler for the Channel shutting down. */ @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { try { + logger.fine("Network channel is closed"); goAwayStatus(goAwayStatus().augmentDescription("Network channel closed")); // Report status to the application layer for any open streams connection().forEachActiveStream(new Http2StreamVisitor() { @@ -210,6 +220,8 @@ class NettyClientHandler extends Http2ConnectionHandler { @Override protected void onConnectionError(ChannelHandlerContext ctx, Throwable cause, Http2Exception http2Ex) { + logger.fine("Caught a connection error", cause); + // Save the error. connectionError = cause; goAwayStatus(Status.fromThrowable(connectionError));