Skip to content

Commit f6b6b42

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 9ed24f2 commit f6b6b42

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
@@ -214,7 +214,8 @@ private <T> ListenableFuture<T> sendRequestWithOpenChannel(Request request, Prox
214214
if (asyncHandler instanceof AsyncHandlerExtensions)
215215
AsyncHandlerExtensions.class.cast(asyncHandler).onConnectionPooled(channel);
216216

217-
scheduleRequestTimeout(future);
217+
TimeoutsHolder timeoutsHolder = scheduleRequestTimeout(future);
218+
timeoutsHolder.initRemoteAddress((InetSocketAddress) channel.remoteAddress());
218219
future.setChannelState(ChannelState.POOLED);
219220
future.attachChannel(channel, false);
220221

@@ -376,10 +377,11 @@ private void configureTransferAdapter(AsyncHandler<?> handler, HttpRequest httpR
376377
TransferCompletionHandler.class.cast(handler).headers(h);
377378
}
378379

379-
private void scheduleRequestTimeout(NettyResponseFuture<?> nettyResponseFuture) {
380+
private TimeoutsHolder scheduleRequestTimeout(NettyResponseFuture<?> nettyResponseFuture) {
380381
nettyResponseFuture.touch();
381382
TimeoutsHolder timeoutsHolder = new TimeoutsHolder(nettyTimer, nettyResponseFuture, this, config);
382383
nettyResponseFuture.setTimeoutsHolder(timeoutsHolder);
384+
return timeoutsHolder;
383385
}
384386

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

0 commit comments

Comments
 (0)