Skip to content

Commit 8b5ca63

Browse files
committed
Re-enable local address binding (required api changes on the Grizzly side).
1 parent f699b28 commit 8b5ca63

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

providers/grizzly/src/main/java/org/asynchttpclient/providers/grizzly/ConnectionManager.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.glassfish.grizzly.utils.IdleTimeoutFilter;
3030

3131
import java.io.IOException;
32+
import java.net.InetAddress;
3233
import java.net.InetSocketAddress;
3334
import java.net.SocketAddress;
3435
import java.net.URI;
@@ -158,6 +159,11 @@ private EndpointKey<SocketAddress> getEndPointKey(final Request request,
158159
if (key == null) {
159160
SocketAddress address =
160161
getRemoteAddress(request, proxyServer);
162+
InetAddress localAddress = request.getLocalAddress();
163+
InetSocketAddress localSocketAddress = null;
164+
if (localAddress != null) {
165+
localSocketAddress = new InetSocketAddress(localAddress.getHostName(), 0);
166+
}
161167
ProxyAwareConnectorHandler handler =
162168
ProxyAwareConnectorHandler
163169
.builder(provider.clientTransport)
@@ -169,8 +175,9 @@ private EndpointKey<SocketAddress> getEndPointKey(final Request request,
169175
.build();
170176
EndpointKey<SocketAddress> localKey =
171177
new EndpointKey<SocketAddress>(stringKey,
172-
address,
173-
handler);
178+
address,
179+
localSocketAddress,
180+
handler);
174181
endpointKeyMap.put(stringKey, localKey);
175182
key = localKey;
176183
}

0 commit comments

Comments
 (0)