Skip to content

Commit c25f436

Browse files
committed
Add logs
1 parent bdc9523 commit c25f436

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncConnectExec.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ public void completed(final AsyncExecRuntime execRuntime) {
255255
asyncExecCallback.failed(new HttpException("Proxy chains are not supported"));
256256
return;
257257
}
258+
if (LOG.isDebugEnabled()) {
259+
LOG.debug("{} H2 tunnel to target already established by connection pool", exchangeId);
260+
}
258261
tracker.tunnelTarget(false);
259262
if (route.isLayered()) {
260263
tracker.layerProtocol(route.isSecure());

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/InternalH2ConnPool.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
import org.apache.hc.core5.reactor.ssl.TransportSecurityLayer;
7171
import org.apache.hc.core5.util.TimeValue;
7272
import org.apache.hc.core5.util.Timeout;
73+
import org.slf4j.Logger;
74+
import org.slf4j.LoggerFactory;
7375

7476
class InternalH2ConnPool implements ModalCloseable {
7577

@@ -176,6 +178,7 @@ public void setValidateAfterInactivity(final TimeValue timeValue) {
176178

177179
static class SessionPool extends AbstractIOSessionPool<HttpRoute> {
178180

181+
private static final Logger LOG = LoggerFactory.getLogger(InternalH2ConnPool.class);
179182
private static final int MAX_TUNNEL_AUTH_ATTEMPTS = 3;
180183

181184
private final ConnectionInitiator connectionInitiator;
@@ -284,6 +287,9 @@ private void completeConnection(
284287
}
285288
final NamedEndpoint targetEndpoint = route.getTargetName() != null ? route.getTargetName() : route.getTargetHost();
286289
final HttpHost proxy = route.getProxyHost();
290+
if (LOG.isDebugEnabled()) {
291+
LOG.debug("{} establishing H2 tunnel to {} via {}", ioSession.getId(), targetEndpoint, proxy);
292+
}
287293
if (proxy != null && proxyHttpProcessor != null && proxyAuthStrategy != null && authenticator != null) {
288294
establishTunnelWithAuth(route, ioSession, targetEndpoint, proxy, connectTimeout, callback);
289295
} else {
@@ -375,6 +381,10 @@ public void failed(final Exception ex) {
375381
proxyHttpProcessor.process(response, null, tunnelContext);
376382
final boolean retry = needAuthentication(proxyAuthExchange, proxy, response, tunnelContext);
377383
if (retry) {
384+
if (LOG.isDebugEnabled()) {
385+
LOG.debug("{} tunnel auth challenge from {}; attempt {}/{}",
386+
ioSession.getId(), proxy, attemptCount, MAX_TUNNEL_AUTH_ATTEMPTS);
387+
}
378388
establishTunnelWithAuthAttempt(
379389
route,
380390
ioSession,
@@ -388,8 +398,6 @@ public void failed(final Exception ex) {
388398
} else {
389399
callback.failed(ex);
390400
}
391-
} catch (final AuthenticationException | MalformedChallengeException authEx) {
392-
callback.failed(authEx);
393401
} catch (final Exception ioEx) {
394402
callback.failed(ioEx);
395403
}

0 commit comments

Comments
 (0)