Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1373,19 +1373,25 @@ 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;
if (override != null) {
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()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small correction to the description: the guard in sendRequestWithOpenChannel also hoists getNettyRequest().getHttpRequest() inside the branch, so it is not purely about the varargs array. The precedent stands, the reasoning is just a bit wider there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected in the description. It hoists getNettyRequest().getHttpRequest() into the branch as well, so two calls are skipped on top of the array. The precedent still holds, the reasoning there is just wider than here.

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;
Expand All @@ -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()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the common path and there is nothing here saying why the guard exists. Moving the comment up would cover it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same move covers this one. The note is above the override branch now, so it reads before either poll.

LOGGER.debug("Using pooled Channel '{}' for '{}' to '{}'", channel, request.getMethod(), uri);
}
return channel;
Expand Down
Loading