Skip to content

Commit d7a0668

Browse files
committed
Cancel timeouts asap, close AsyncHttpClient#848
1 parent 0b3efcf commit d7a0668

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/main/java/com/ning/http/client/providers/netty/future/NettyResponseFuture.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ private V getContent() throws ExecutionException {
200200

201201
private boolean terminateAndExit() {
202202
cancelTimeouts();
203+
this.channel = null;
204+
this.reuseChannel = false;
203205
return isDone.getAndSet(true) || isCancelled.get();
204206
}
205207

@@ -389,11 +391,6 @@ public void attachChannel(Channel channel, boolean reuseChannel) {
389391
this.reuseChannel = reuseChannel;
390392
}
391393

392-
public void detachChannel() {
393-
this.channel = null;
394-
this.reuseChannel = false;
395-
}
396-
397394
public Channel channel() {
398395
return channel;
399396
}

src/main/java/com/ning/http/client/providers/netty/handler/HttpProtocol.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ private void addType3NTLMAuthorizationHeader(String auth, FluentCaseInsensitiveS
181181

182182
private void finishUpdate(final NettyResponseFuture<?> future, Channel channel, boolean expectOtherChunks) throws IOException {
183183

184-
future.detachChannel();
184+
// cancel timeouts asap so they don't trigger while draining the channel or offering to the pool
185+
future.cancelTimeouts();
185186

186187
boolean keepAlive = future.isKeepAlive();
187188
if (expectOtherChunks && keepAlive)

0 commit comments

Comments
 (0)