Skip to content

Commit dfc01fa

Browse files
committed
Fix NPE on scheduleReadTimeout on fast requests, close AsyncHttpClient#1068
1 parent e862ece commit dfc01fa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,13 @@ private void scheduleRequestTimeout(NettyResponseFuture<?> nettyResponseFuture)
360360
}
361361

362362
private void scheduleReadTimeout(NettyResponseFuture<?> nettyResponseFuture) {
363-
nettyResponseFuture.touch();
364363
TimeoutsHolder timeoutsHolder = nettyResponseFuture.getTimeoutsHolder();
365-
timeoutsHolder.startReadTimeout();
364+
if (timeoutsHolder != null) {
365+
// on very fast requests, it's entirely possible that the response has already been completed
366+
// by the time we try to schedule the read timeout
367+
nettyResponseFuture.touch();
368+
timeoutsHolder.startReadTimeout();
369+
}
366370
}
367371

368372
public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) {

0 commit comments

Comments
 (0)