From 5ebdee8537a3c953582351212b0b53c16f40b613 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 dc9e8218f3..302ff08208 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 @@ -33,7 +33,6 @@ import io.netty.util.ReferenceCounted; import io.netty.util.collection.IntObjectHashMap; import io.netty.util.collection.IntObjectMap; 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; @@ -41,6 +40,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. @@ -569,14 +569,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