Skip to content

Commit 495eaef

Browse files
author
Stephane Landelle
committed
Clean up: don't throw in finally blocks
1 parent 34fa953 commit 495eaef

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,17 @@ public V get(long l, TimeUnit tu) throws InterruptedException, TimeoutException,
241241
} catch (Throwable t) {
242242
// Ignore
243243
}
244-
TimeoutException te = new TimeoutException(String.format("No response received after %s", l));
245244
if (!throwableCalled.getAndSet(true)) {
246245
try {
247-
asyncHandler.onThrowable(te);
248-
} catch (Throwable t) {
249-
logger.debug("asyncHandler.onThrowable", t);
246+
TimeoutException te = new TimeoutException(String.format("No response received after %s", l));
247+
try {
248+
asyncHandler.onThrowable(te);
249+
} catch (Throwable t) {
250+
logger.debug("asyncHandler.onThrowable", t);
251+
}
252+
throw new ExecutionException(te);
250253
} finally {
251254
cancelReaper();
252-
throw new ExecutionException(te);
253255
}
254256
}
255257
}
@@ -278,12 +280,14 @@ V getContent() throws ExecutionException {
278280
} catch (Throwable ex) {
279281
if (!throwableCalled.getAndSet(true)) {
280282
try {
281-
asyncHandler.onThrowable(ex);
282-
} catch (Throwable t) {
283-
logger.debug("asyncHandler.onThrowable", t);
283+
try {
284+
asyncHandler.onThrowable(ex);
285+
} catch (Throwable t) {
286+
logger.debug("asyncHandler.onThrowable", t);
287+
}
288+
throw new RuntimeException(ex);
284289
} finally {
285290
cancelReaper();
286-
throw new RuntimeException(ex);
287291
}
288292
}
289293
}

0 commit comments

Comments
 (0)