Open alechenninger opened 8 years ago
Is this because if (isDone()) return;
happens first in the complete methods on LazyTransformingFuture and LazyTransformableFuture?
No, if you look here:
@Override
public <V> TransformableFuture<V> transformSync(FutureTransform<U, V> futureTransform) {
LazyTransformingFuture<U, V> future =
new LazyTransformingFuture<>(futureTransform, completer);
next.add(future);
return future;
}
All this does is add it to the list of next futures to complete once we have a result.
What if we already have a result? The newly added futures will never be completed.
So in this method, we need to atomically check if the future is already completed, and in that case just complete the passed in future immediately, synchronously. Otherwise, add it to next.
Hasn't been a problem in practice by nature of their laziness, but this should be fixed. Shouldn't be hard.