From 37c03cce5e95fb200b3dc5b234b46fe0a281bdec Mon Sep 17 00:00:00 2001 From: Idel Pivnitskiy Date: Fri, 3 Sep 2021 01:53:36 -0500 Subject: [PATCH] Include number of maximum active streams in exception message (#11644) Motivation: When users receive "Maximum active streams violated for this endpoint" exception, it's useful to know what is the current max streams limit on HTTP/2 connection. Modifications: - Include current number of maximum active streams in exception message; Result: Easier debugging of HTTP/2 connections. --- .../handler/codec/http2/DefaultHttp2Connection.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java index 5c622d6f73..dd9680e653 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Connection.java @@ -483,8 +483,10 @@ public class DefaultHttp2Connection implements Http2Connection { @Override public Http2Stream open(boolean halfClosed) throws Http2Exception { state = activeState(id, state, isLocal(), halfClosed); - if (!createdBy().canOpenStream()) { - throw connectionError(PROTOCOL_ERROR, "Maximum active streams violated for this endpoint."); + final DefaultEndpoint endpoint = createdBy(); + if (!endpoint.canOpenStream()) { + throw connectionError(PROTOCOL_ERROR, "Maximum active streams violated for this endpoint: " + + endpoint.maxActiveStreams()); } activate(); @@ -897,7 +899,8 @@ public class DefaultHttp2Connection implements Http2Connection { } boolean isReserved = state == RESERVED_LOCAL || state == RESERVED_REMOTE; if (!isReserved && !canOpenStream() || isReserved && numStreams >= maxStreams) { - throw streamError(streamId, REFUSED_STREAM, "Maximum active streams violated for this endpoint."); + throw streamError(streamId, REFUSED_STREAM, "Maximum active streams violated for this endpoint: " + + (isReserved ? maxStreams : maxActiveStreams)); } if (isClosed()) { throw connectionError(INTERNAL_ERROR, "Attempted to create stream id %d after connection was closed",