8303742: CompletableFuture.orTimeout leaks if the future completes exceptionally

Reviewed-by: jpai, alanb
This commit is contained in:
Viktor Klang 2023-03-20 13:55:47 +00:00 committed by Jaikiran Pai
parent 652bda0af8
commit ded6a81319
2 changed files with 64 additions and 1 deletions

View file

@ -2937,7 +2937,7 @@ public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
final Future<?> f;
Canceller(Future<?> f) { this.f = f; }
public void accept(Object ignore, Throwable ex) {
if (ex == null && f != null && !f.isDone())
if (f != null && !f.isDone())
f.cancel(false);
}
}