3819 |
|
CompletableFuture<? extends T> g) { |
3820 |
|
PlusFuture<T> plus = new PlusFuture<T>(); |
3821 |
|
BiConsumer<T, Throwable> action = (T result, Throwable ex) -> { |
3822 |
< |
if (result != null) { |
3822 |
> |
if (ex == null) { |
3823 |
|
if (plus.complete(result)) |
3824 |
|
if (plus.firstFailure.get() != null) |
3825 |
|
plus.firstFailure.set(null); |
3828 |
|
if (plus.isDone()) |
3829 |
|
plus.firstFailure.set(null); |
3830 |
|
} else { |
3831 |
< |
if (plus.completeExceptionally(ex)) |
3832 |
< |
plus.firstFailure.set(null); |
3831 |
> |
// prefer failing with first failure |
3832 |
> |
plus.completeExceptionally(plus.firstFailure.getAndSet(null)); |
3833 |
|
} |
3834 |
|
}; |
3835 |
|
f.whenComplete(action); |