Skip to content

Commit eaaf64a

Browse files
committed
Initialize timeout remote address when channel was pooled, close AsyncHttpClient#1363
Motivation: When channel was fetched from pool, we fail to initialize the remote address, causing timeout exceptions to say «not-connected ». Modification: Properly initialize Result: No more erroneous « not-connected ».  
1 parent 555d131 commit eaaf64a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

client/src/main/java/org/asynchttpclient/netty/request/NettyRequestSender.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ private <T> ListenableFuture<T> sendRequestWithOpenChannel(Request request, Prox
216216
if (asyncHandler instanceof AsyncHandlerExtensions)
217217
AsyncHandlerExtensions.class.cast(asyncHandler).onConnectionPooled(channel);
218218

219-
scheduleRequestTimeout(future);
219+
TimeoutsHolder timeoutsHolder = scheduleRequestTimeout(future);
220+
timeoutsHolder.initRemoteAddress((InetSocketAddress) channel.remoteAddress());
220221
future.setChannelState(ChannelState.POOLED);
221222
future.attachChannel(channel, false);
222223

@@ -378,10 +379,11 @@ private void configureTransferAdapter(AsyncHandler<?> handler, HttpRequest httpR
378379
TransferCompletionHandler.class.cast(handler).headers(h);
379380
}
380381

381-
private void scheduleRequestTimeout(NettyResponseFuture<?> nettyResponseFuture) {
382+
private TimeoutsHolder scheduleRequestTimeout(NettyResponseFuture<?> nettyResponseFuture) {
382383
nettyResponseFuture.touch();
383384
TimeoutsHolder timeoutsHolder = new TimeoutsHolder(nettyTimer, nettyResponseFuture, this, config);
384385
nettyResponseFuture.setTimeoutsHolder(timeoutsHolder);
386+
return timeoutsHolder;
385387
}
386388

387389
private void scheduleReadTimeout(NettyResponseFuture<?> nettyResponseFuture) {

0 commit comments

Comments
 (0)