Skip to content

Commit

Permalink
fix ListenableFutureUtils#toCompletableFuture cancellation propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
linzee1 authored and oldratlee committed Jul 22, 2024
1 parent 3036128 commit 5dcd812
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public String toString() {
}
};
// propagate cancellation by CancellationException from outer adapter to LF
CompletableFutureUtils.peek(ret, (v, ex) -> lf.cancel(false));
CompletableFutureUtils.peek(ret, (v, ex) -> {
ex = CompletableFutureUtils.unwrapCfException(ex);
if (ex instanceof CancellationException) {
lf.cancel(false);
}
});

Futures.addCallback(lf, new FutureCallback<T>() {
@Override
Expand Down

0 comments on commit 5dcd812

Please sign in to comment.