Porting issue 36 from the enterprise repo
rkhadiwa commented on Nov 29, 2017
From CompletionStage javadoc, toCompletableFuture is optional.
* A CompletionStage
* implementation that does not choose to interoperate with others
* may throw {@code UnsupportedOperationException}.
*
* @return the CompletableFuture
* @throws UnsupportedOperationException if this implementation
* does not interoperate with CompletableFuture
public static CompletionStage<Void> allOf(
final Collection<? extends CompletionStage<?>> stages) {
final Iterator<? extends CompletionStage<?>> backingIt = stages.iterator();
final int size = stages.size();
final Iterator<? extends CompletionStage<?>> it =
size > MAX_DEPENDANT_DEPTH
? new Iterator<CompletionStage<?>>() {
@Override
public boolean hasNext() {
return backingIt.hasNext();
}
@Override
public CompletionStage<?> next() {
return backingIt.next().toCompletableFuture();
}
}
: backingIt;
return allOfImpl(it);
}
Just a rant, toCompletableFuture is so stupid.
Because it exists, CompletionStage isn't actually read only since CompletableFuture.toCompletableFuture returns this (and worse than a user completing a stage, the user can also use obtrude*). But because it's optional you can't depend on it for what little use it actually did have (interop).
Porting issue 36 from the enterprise repo
rkhadiwa commented on Nov 29, 2017
From CompletionStage javadoc, toCompletableFuture is optional.
Just a rant,
toCompletableFutureis so stupid.Because it exists,
CompletionStageisn't actually read only sinceCompletableFuture.toCompletableFuturereturnsthis(and worse than a user completing a stage, the user can also useobtrude*). But because it's optional you can't depend on it for what little use it actually did have (interop).