From ffa693b3d560d5078f0cc4c7787bdba9f1232c50 Mon Sep 17 00:00:00 2001 From: Jerry Lee Date: Sat, 17 Aug 2024 18:21:55 +0800 Subject: [PATCH] docs: also add the javadoc comments of JDK bug info at internal `FutureCanceller` class --- .../java/io/foldright/cffu/CompletableFutureUtils.java | 6 ++++-- .../main/java/io/foldright/cffu/DelayExecutionHelpers.java | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java index 337e1505..b18a9892 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java +++ b/cffu-core/src/main/java/io/foldright/cffu/CompletableFutureUtils.java @@ -3727,9 +3727,11 @@ public static > C cffuOrTimeout( * is one less thread switch of task execution when triggered by timeout. *

* Note: Before Java 21(Java 20-), {@link CompletableFuture#orTimeout(long, TimeUnit)} - * can leak if the future completes exceptionally, more info see - * JDK-8303742 + * leaks if the future completes exceptionally, more info see + * issue JDK-8303742, + * PR review openjdk/jdk/13059 * and JDK bugfix commit. + * The cffu backport logic(for Java 8) has merged the fix of this JDK bug. * * @param timeout how long to wait before completing exceptionally with a TimeoutException, in units of {@code unit} * @param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter diff --git a/cffu-core/src/main/java/io/foldright/cffu/DelayExecutionHelpers.java b/cffu-core/src/main/java/io/foldright/cffu/DelayExecutionHelpers.java index 8f4325ff..76bf04bf 100644 --- a/cffu-core/src/main/java/io/foldright/cffu/DelayExecutionHelpers.java +++ b/cffu-core/src/main/java/io/foldright/cffu/DelayExecutionHelpers.java @@ -200,6 +200,13 @@ final class FutureCanceller implements BiConsumer { this.f = requireNonNull(f); } + /** + * Note: Before Java 21(Java 20-), {@link CompletableFuture#orTimeout(long, TimeUnit)} + * leaks if the future completes exceptionally, more info see + * issue JDK-8303742, + * PR review openjdk/jdk/13059 + * and JDK bugfix commit. + */ @Override public void accept(Object ignore, @Nullable Throwable ex) { if (f != null && !f.isDone())