diff --git a/client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java b/client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java index fc7956c4d..a6601d57d 100755 --- a/client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java +++ b/client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java @@ -1373,6 +1373,10 @@ private Channel pollPooledChannel(NettyResponseFuture future, Request request Uri uri = request.getUri(); String virtualHost = request.getVirtualHost(); + // SLF4J has no three-argument overload, so every debug statement below binds to + // debug(String, Object...) and allocates its varargs array at the call site whatever the level. This + // is the steady-state connection-reuse path, so they are all guarded explicitly. + // Round-robin mode: poll with the IP-aware key so reuse stays pinned to the chosen IP (both the // HTTP/2 registry and the HTTP/1.1 pool). Object override = future != null ? future.getPartitionKeyOverride() : null; @@ -1380,12 +1384,14 @@ private Channel pollPooledChannel(NettyResponseFuture future, Request request if (!uri.isWebSocket()) { Channel h2Channel = channelManager.pollHttp2Connection(override); if (h2Channel != null) { - LOGGER.debug("Using HTTP/2 multiplexed Channel '{}' for '{}' to '{}'", h2Channel, request.getMethod(), uri); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Using HTTP/2 multiplexed Channel '{}' for '{}' to '{}'", h2Channel, request.getMethod(), uri); + } return h2Channel; } } Channel channel = channelManager.poll(override); - if (channel != null) { + if (channel != null && LOGGER.isDebugEnabled()) { LOGGER.debug("Using pooled Channel '{}' for '{}' to '{}'", channel, request.getMethod(), uri); } return channel; @@ -1406,14 +1412,16 @@ private Channel pollPooledChannel(NettyResponseFuture future, Request request if (!uri.isWebSocket()) { Channel h2Channel = channelManager.pollHttp2Connection(partitionKey); if (h2Channel != null) { - LOGGER.debug("Using HTTP/2 multiplexed Channel '{}' for '{}' to '{}'", h2Channel, request.getMethod(), uri); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Using HTTP/2 multiplexed Channel '{}' for '{}' to '{}'", h2Channel, request.getMethod(), uri); + } return h2Channel; } } final Channel channel = channelManager.poll(partitionKey); - if (channel != null) { + if (channel != null && LOGGER.isDebugEnabled()) { LOGGER.debug("Using pooled Channel '{}' for '{}' to '{}'", channel, request.getMethod(), uri); } return channel;