Skip to content

Commit 8add587

Browse files
author
Stephane Landelle
committed
Make sure a cancel exception won't hide the expected one
1 parent 20deaa8 commit 8add587

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

providers/netty/src/main/java/org/asynchttpclient/providers/netty/future/NettyResponseFuture.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,15 @@ public V get(long l, TimeUnit tu) throws InterruptedException, TimeoutException,
234234
TimeoutException te = new TimeoutException(String.format("No response received after %s %s", l, tu.name().toLowerCase()));
235235
if (!throwableCalled.getAndSet(true)) {
236236
try {
237-
asyncHandler.onThrowable(te);
238-
} catch (Throwable t) {
239-
logger.debug("asyncHandler.onThrowable", t);
237+
try {
238+
asyncHandler.onThrowable(te);
239+
} catch (Throwable t) {
240+
logger.debug("asyncHandler.onThrowable", t);
241+
}
242+
throw new ExecutionException(te);
243+
} finally {
244+
cancelReaper();
240245
}
241-
cancelReaper();
242-
throw new ExecutionException(te);
243246
}
244247
}
245248
isDone.set(true);
@@ -267,12 +270,15 @@ private V getContent() throws ExecutionException {
267270
} catch (Throwable ex) {
268271
if (!throwableCalled.getAndSet(true)) {
269272
try {
270-
asyncHandler.onThrowable(ex);
271-
} catch (Throwable t) {
272-
logger.debug("asyncHandler.onThrowable", t);
273+
try {
274+
asyncHandler.onThrowable(ex);
275+
} catch (Throwable t) {
276+
logger.debug("asyncHandler.onThrowable", t);
277+
}
278+
throw new RuntimeException(ex);
279+
} finally {
280+
cancelReaper();
273281
}
274-
cancelReaper();
275-
throw new RuntimeException(ex);
276282
}
277283
}
278284
content.compareAndSet(null, update);

0 commit comments

Comments
 (0)