Skip to content

Commit 1bf36f4

Browse files
committed
Corrected localAddress logic
1 parent 0245ef3 commit 1bf36f4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,13 +987,16 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand
987987
remoteAddress = new InetSocketAddress(request.getInetAddress(), AsyncHttpProviderUtils.getPort(uri));
988988
} else if (proxyServer == null || avoidProxy) {
989989
remoteAddress = new InetSocketAddress(AsyncHttpProviderUtils.getHost(uri), AsyncHttpProviderUtils.getPort(uri));
990-
} else if(request.getLocalAddress() != null) {
991-
remoteAddress = new InetSocketAddress(request.getLocalAddress(), 0);
992990
} else {
993991
remoteAddress = new InetSocketAddress(proxyServer.getHost(), proxyServer.getPort());
994992
}
995993

996-
channelFuture = bootstrap.connect(remoteAddress);
994+
if(request.getLocalAddress() != null){
995+
channelFuture = bootstrap.connect(remoteAddress, new InetSocketAddress(request.getLocalAddress(), 0));
996+
}else{
997+
channelFuture = bootstrap.connect(remoteAddress);
998+
}
999+
9971000
} catch (Throwable t) {
9981001
if (acquiredConnection) {
9991002
freeConnections.release();

0 commit comments

Comments
 (0)