Skip to content

Commit 8894930

Browse files
committed
Channel can be null when crash happened just after connecting, see AsyncHttpClient#1070
1 parent 458f391 commit 8894930

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,11 @@ public boolean applyIoExceptionFiltersAndReplayRequest(NettyResponseFuture<?> fu
442442

443443
public <T> void sendNextRequest(final Request request, final NettyResponseFuture<T> future) {
444444
// remove attribute in case the channel gets closed so it doesn't try to recover the previous future
445-
Channels.setAttribute(future.channel(), null);
445+
Channel channel = future.channel();
446+
if (channel != null) {
447+
// channel can be null when it was closed by the server before it could be set
448+
Channels.setAttribute(channel, null);
449+
}
446450
sendRequest(request, future.getAsyncHandler(), future, true);
447451
}
448452

0 commit comments

Comments
 (0)