Skip to content

Commit 6b90b0a

Browse files
author
Stephane Landelle
committed
Pool key is not properly computed when proxy is defined, close AsyncHttpClient#508
1 parent d850e4e commit 6b90b0a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ public ChannelPipeline getPipeline() throws Exception {
417417
}
418418
}
419419

420-
private Channel lookupInCache(URI uri, ConnectionPoolKeyStrategy connectionPoolKeyStrategy) {
421-
final Channel channel = connectionsPool.poll(connectionPoolKeyStrategy.getKey(uri));
420+
private Channel lookupInCache(URI uri, ProxyServer proxy, ConnectionPoolKeyStrategy strategy) {
421+
final Channel channel = connectionsPool.poll(getPoolKey(uri, proxy, strategy));
422422

423423
if (channel != null) {
424424
log.debug("Using cached Channel {}\n for uri {}\n", channel, uri);
@@ -942,8 +942,7 @@ private <T> NettyResponseFuture<T> buildNettyResponseFutureWithCachedChannel(Req
942942
if (f != null && f.reuseChannel() && f.channel() != null) {
943943
channel = f.channel();
944944
} else {
945-
URI connectionKeyUri = proxyServer != null ? proxyServer.getURI() : uri;
946-
channel = lookupInCache(connectionKeyUri, request.getConnectionPoolKeyStrategy());
945+
channel = lookupInCache(uri, proxyServer, request.getConnectionPoolKeyStrategy());
947946
}
948947

949948
if (channel == null)
@@ -1318,10 +1317,11 @@ private Realm ntlmProxyChallenge(List<String> wwwAuth, Request request, ProxySer
13181317
}
13191318

13201319
private String getPoolKey(NettyResponseFuture<?> future) {
1321-
1322-
String serverPart = future.getConnectionPoolKeyStrategy().getKey(future.getURI());
1323-
1324-
ProxyServer proxy = future.getProxyServer();
1320+
return getPoolKey(future.getURI(), future.getProxyServer(), future.getConnectionPoolKeyStrategy());
1321+
}
1322+
1323+
private String getPoolKey(URI uri, ProxyServer proxy, ConnectionPoolKeyStrategy strategy) {
1324+
String serverPart = strategy.getKey(uri);
13251325
return proxy != null ? AsyncHttpProviderUtils.getBaseUrl(proxy.getURI()) + serverPart : serverPart;
13261326
}
13271327

0 commit comments

Comments
 (0)