1027 |
|
private CompletableFuture<T> uniComposeExceptionallyStage( |
1028 |
|
Executor e, Function<Throwable, ? extends CompletionStage<T>> f) { |
1029 |
|
if (f == null) throw new NullPointerException(); |
1030 |
< |
CompletableFuture<T> d = newIncompleteFuture(); |
1031 |
< |
Object r, s; Throwable x; |
1030 |
> |
final CompletableFuture<T> d; |
1031 |
> |
Object r; Throwable x; |
1032 |
|
if ((r = result) == null) |
1033 |
< |
unipush(new UniComposeExceptionally<T>(e, d, this, f)); |
1034 |
< |
else if (e == null) { |
1035 |
< |
if ((r instanceof AltResult) && (x = ((AltResult)r).ex) != null) { |
1036 |
< |
try { |
1037 |
< |
CompletableFuture<T> g = f.apply(x).toCompletableFuture(); |
1038 |
< |
if ((s = g.result) != null) |
1039 |
< |
d.result = encodeRelay(s); |
1040 |
< |
else { |
1041 |
< |
g.unipush(new UniRelay<T,T>(d, g)); |
1042 |
< |
} |
1043 |
< |
} catch (Throwable ex) { |
1044 |
< |
d.result = encodeThrowable(ex); |
1045 |
< |
} |
1046 |
< |
} |
1047 |
< |
else |
1048 |
< |
d.internalComplete(r); |
1049 |
< |
} |
1033 |
> |
unipush(new UniComposeExceptionally<T>( |
1034 |
> |
e, d = newIncompleteFuture(), this, f)); |
1035 |
> |
else if (!(r instanceof AltResult) || (x = ((AltResult)r).ex) == null) |
1036 |
> |
return this; |
1037 |
|
else |
1038 |
|
try { |
1039 |
< |
e.execute(new UniComposeExceptionally<T>(null, d, this, f)); |
1039 |
> |
if (e == null) |
1040 |
> |
return f.apply(x).toCompletableFuture(); |
1041 |
> |
else |
1042 |
> |
e.execute(new UniComposeExceptionally<T>( |
1043 |
> |
null, d = newIncompleteFuture(), this, f)); |
1044 |
|
} catch (Throwable ex) { |
1045 |
< |
d.result = encodeThrowable(ex); |
1045 |
> |
return new CompletableFuture<T>(encodeThrowable(ex)); |
1046 |
|
} |
1047 |
|
return d; |
1048 |
|
} |
1049 |
|
|
1059 |
– |
|
1050 |
|
@SuppressWarnings("serial") |
1051 |
|
static final class UniRelay<U, T extends U> extends UniCompletion<T,U> { |
1052 |
|
UniRelay(CompletableFuture<U> dep, CompletableFuture<T> src) { |