Skip to content

Commit 3e19b9c

Browse files
committed
possible fix to issue AsyncHttpClient#114 where if the request times out, we cancel the future (as before); but now also directly make a call to close the channel. Not sure if this impact any pooling on that channel though.
1 parent 9d75ba8 commit 3e19b9c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,13 @@ public V get(long l, TimeUnit tu) throws InterruptedException, TimeoutException,
211211
}
212212

213213
if (expired) {
214-
isCancelled.set(true);
214+
isCancelled.set(false);
215+
try {
216+
channel.getPipeline().getContext(NettyAsyncHttpProvider.class).setAttachment(new NettyAsyncHttpProvider.DiscardEvent());
217+
channel.close();
218+
} catch (Throwable t) {
219+
// Ignore
220+
}
215221
TimeoutException te = new TimeoutException(String.format("No response received after %s %s", l, tu.name().toLowerCase()));
216222
if (!throwableCalled.getAndSet(true)) {
217223
try {

0 commit comments

Comments
 (0)