CompletionStage<T>.await()
is broken for MinimalStage
#2456
Labels
CompletionStage<T>.await()
is broken for MinimalStage
#2456
Many JDK methods that return
CompletionStage
are internally implemented using a class calledMinimalStage
, which inherits implementation fromCompletableFuture
(and therefore extendsFuture
at runtime) but throwsUnsupportedOperationException
at runtime for mostFuture
methods e.g.isDone()
. Provided the caller uses the declared return type ofCompletionStage
this doesn't matter.Unfortunately
CompletionStage<T>.await()
checks reflectively whether the passedCompletionStage
implementsFuture
and then callsFuture#isDone()
if it does, leading to an exception like:Minimal reproduction (tested on JDK11):
The text was updated successfully, but these errors were encountered: