Skip to content

Commit d9790c2

Browse files
author
Stephane Landelle
committed
Abort and cancel should set cancelled early, close AsyncHttpClient#477
1 parent c041a2d commit d9790c2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void setAsyncHandler(AsyncHandler<V> asyncHandler) {
163163
public boolean cancel(boolean force) {
164164
cancelTimeouts();
165165

166-
if (isCancelled.get())
166+
if (isCancelled.getAndSet(true))
167167
return false;
168168

169169
try {
@@ -180,7 +180,6 @@ public boolean cancel(boolean force) {
180180
}
181181
}
182182
latch.countDown();
183-
isCancelled.set(true);
184183
runListeners();
185184
return true;
186185
}
@@ -335,17 +334,16 @@ public final void done() {
335334
public final void abort(final Throwable t) {
336335
cancelTimeouts();
337336

338-
if (isDone.get() || isCancelled.get())
337+
if (isDone.get() || isCancelled.getAndSet(true))
339338
return;
340339

340+
isCancelled.set(true);
341341
exEx.compareAndSet(null, new ExecutionException(t));
342342
if (onThrowableCalled.compareAndSet(false, true)) {
343343
try {
344344
asyncHandler.onThrowable(t);
345345
} catch (Throwable te) {
346346
logger.debug("asyncHandler.onThrowable", te);
347-
} finally {
348-
isCancelled.set(true);
349347
}
350348
}
351349
latch.countDown();

0 commit comments

Comments
 (0)