1027 |
|
private CompletableFuture<T> uniComposeExceptionallyStage( |
1028 |
|
Executor e, Function<Throwable, ? extends CompletionStage<T>> f) { |
1029 |
|
if (f == null) throw new NullPointerException(); |
1030 |
< |
final CompletableFuture<T> d; |
1031 |
< |
Object r; Throwable x; |
1030 |
> |
CompletableFuture<T> d = newIncompleteFuture(); |
1031 |
> |
Object r, s; Throwable x; |
1032 |
|
if ((r = result) == null) |
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; |
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 |
> |
} |
1050 |
|
else |
1051 |
|
try { |
1052 |
< |
if (e == null) |
1040 |
< |
return f.apply(x).toCompletableFuture(); |
1041 |
< |
else |
1042 |
< |
e.execute(new UniComposeExceptionally<T>( |
1043 |
< |
null, d = newIncompleteFuture(), this, f)); |
1052 |
> |
e.execute(new UniComposeExceptionally<T>(null, d, this, f)); |
1053 |
|
} catch (Throwable ex) { |
1054 |
< |
return new CompletableFuture<T>(encodeThrowable(ex)); |
1054 |
> |
d.result = encodeThrowable(ex); |
1055 |
|
} |
1056 |
|
return d; |
1057 |
|
} |