From 6a2b9a76fe3f79cee679c5e44479974cdf856c59 Mon Sep 17 00:00:00 2001 From: Idel Pivnitskiy Date: Thu, 2 Sep 2021 12:11:46 -0500 Subject: [PATCH] Always log Http2UnknownStreamError at `DEBUG` level (#11643) Motivation: Exception logged by `onHttp2UnknownStreamError` is propagated to the upper layers anyway. Receiver of the exception is responsible for correct handling. Inside netty, it's enough to log at `DEBUG` level. Modifications: - `Http2FrameCodec#onHttp2UnknownStreamError` always logs at `DEBUG` level; Result: Less noise in logs when `Http2UnknownStreamError` is properly handled by upper layers. Co-authored-by: Norman Maurer Co-authored-by: Chris Vest --- .../handler/codec/http2/Http2FrameCodec.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java index d59ffb00cf..a1010c2c20 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2FrameCodec.java @@ -32,7 +32,6 @@ import io.netty.util.collection.IntObjectMap; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.Promise; import io.netty.util.internal.UnstableApi; -import io.netty.util.internal.logging.InternalLogLevel; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; @@ -40,6 +39,7 @@ import static io.netty.buffer.ByteBufUtil.writeAscii; import static io.netty.handler.codec.http2.Http2CodecUtil.HTTP_UPGRADE_STREAM_ID; import static io.netty.handler.codec.http2.Http2CodecUtil.isStreamIdValid; import static io.netty.handler.codec.http2.Http2Error.NO_ERROR; +import static io.netty.util.internal.logging.InternalLogLevel.DEBUG; /** *

This API is very immature. The Http2Connection-based API is currently preferred over this API. @@ -557,14 +557,14 @@ public class Http2FrameCodec extends Http2ConnectionHandler { } } - private void onHttp2UnknownStreamError(@SuppressWarnings("unused") ChannelHandlerContext ctx, Throwable cause, - Http2Exception.StreamException streamException) { - // It is normal to hit a race condition where we still receive frames for a stream that this - // peer has deemed closed, such as if this peer sends a RST(CANCEL) to discard the request. - // Since this is likely to be normal we log at DEBUG level. - InternalLogLevel level = - streamException.error() == Http2Error.STREAM_CLOSED ? InternalLogLevel.DEBUG : InternalLogLevel.WARN; - LOG.log(level, "Stream exception thrown for unknown stream {}.", streamException.streamId(), cause); + private static void onHttp2UnknownStreamError(@SuppressWarnings("unused") ChannelHandlerContext ctx, + Throwable cause, Http2Exception.StreamException streamException) { + // We log here for debugging purposes. This exception will be propagated to the upper layers through other ways: + // - fireExceptionCaught + // - fireUserEventTriggered(Http2ResetFrame), see Http2MultiplexHandler#channelRead(...) + // - by failing write promise + // Receiver of the error is responsible for correct handling of this exception. + LOG.log(DEBUG, "Stream exception thrown for unknown stream {}.", streamException.streamId(), cause); } @Override