Skip to content

Commit

Permalink
docs: also add the javadoc comments of JDK bug info at internal `Futu…
Browse files Browse the repository at this point in the history
…reCanceller` class
  • Loading branch information
oldratlee committed Aug 17, 2024
1 parent 4695801 commit ffa693b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3727,9 +3727,11 @@ public static <C extends CompletableFuture<?>> C cffuOrTimeout(
* is one less thread switch of task execution when triggered by timeout.
* <p>
* Note: Before Java 21(Java 20-), {@link CompletableFuture#orTimeout(long, TimeUnit)}
* can leak if the future completes exceptionally, more info see
* <a href="https://bugs.openjdk.org/browse/JDK-8303742">JDK-8303742</a>
* leaks if the future completes exceptionally, more info see
* <a href="https://bugs.openjdk.org/browse/JDK-8303742">issue JDK-8303742</a>,
* <a href="https://github.com/openjdk/jdk/pull/13059">PR review openjdk/jdk/13059</a>
* and <a href="https://github.com/openjdk/jdk/commit/ded6a8131970ac2f7ae59716769e6f6bae3b809a">JDK bugfix commit</a>.
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ final class FutureCanceller implements BiConsumer<Object, Throwable> {
this.f = requireNonNull(f);
}

/**
* Note: Before Java 21(Java 20-), {@link CompletableFuture#orTimeout(long, TimeUnit)}
* leaks if the future completes exceptionally, more info see
* <a href="https://bugs.openjdk.org/browse/JDK-8303742">issue JDK-8303742</a>,
* <a href="https://github.com/openjdk/jdk/pull/13059">PR review openjdk/jdk/13059</a>
* and <a href="https://github.com/openjdk/jdk/commit/ded6a8131970ac2f7ae59716769e6f6bae3b809a">JDK bugfix commit</a>.
*/
@Override
public void accept(Object ignore, @Nullable Throwable ex) {
if (f != null && !f.isDone())
Expand Down

0 comments on commit ffa693b

Please sign in to comment.