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 <norman_maurer@apple.com>
Co-authored-by: Chris Vest <mr.chrisvest@gmail.com>
This commit is contained in:
Idel Pivnitskiy 2021-09-02 12:11:46 -05:00 committed by GitHub
parent c8c45cfa4c
commit 5ebdee8537
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,7 +33,6 @@ import io.netty.util.ReferenceCounted;
import io.netty.util.collection.IntObjectHashMap; import io.netty.util.collection.IntObjectHashMap;
import io.netty.util.collection.IntObjectMap; import io.netty.util.collection.IntObjectMap;
import io.netty.util.internal.UnstableApi; 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.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory; 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.HTTP_UPGRADE_STREAM_ID;
import static io.netty.handler.codec.http2.Http2CodecUtil.isStreamIdValid; import static io.netty.handler.codec.http2.Http2CodecUtil.isStreamIdValid;
import static io.netty.handler.codec.http2.Http2Error.NO_ERROR; import static io.netty.handler.codec.http2.Http2Error.NO_ERROR;
import static io.netty.util.internal.logging.InternalLogLevel.DEBUG;
/** /**
* <p><em>This API is very immature.</em> The Http2Connection-based API is currently preferred over this API. * <p><em>This API is very immature.</em> 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, private static void onHttp2UnknownStreamError(@SuppressWarnings("unused") ChannelHandlerContext ctx,
Http2Exception.StreamException streamException) { Throwable cause, Http2Exception.StreamException streamException) {
// It is normal to hit a race condition where we still receive frames for a stream that this // We log here for debugging purposes. This exception will be propagated to the upper layers through other ways:
// peer has deemed closed, such as if this peer sends a RST(CANCEL) to discard the request. // - fireExceptionCaught
// Since this is likely to be normal we log at DEBUG level. // - fireUserEventTriggered(Http2ResetFrame), see Http2MultiplexHandler#channelRead(...)
InternalLogLevel level = // - by failing write promise
streamException.error() == Http2Error.STREAM_CLOSED ? InternalLogLevel.DEBUG : InternalLogLevel.WARN; // Receiver of the error is responsible for correct handling of this exception.
LOG.log(level, "Stream exception thrown for unknown stream {}.", streamException.streamId(), cause); LOG.log(DEBUG, "Stream exception thrown for unknown stream {}.", streamException.streamId(), cause);
} }
@Override @Override