ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CompletableFuture.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CompletableFuture.java (file contents):
Revision 1.218 by jsr166, Mon Sep 24 00:20:46 2018 UTC vs.
Revision 1.219 by jsr166, Mon Sep 24 01:23:53 2018 UTC

# Line 1031 | Line 1031 | public class CompletableFuture<T> implem
1031          Object r, s; 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 {
1034 >        else if (!(r instanceof AltResult) || (x = ((AltResult)r).ex) == null)
1035 >            d.internalComplete(r);
1036 >        else
1037 >            try {
1038 >                if (e != null)
1039 >                    e.execute(new UniComposeExceptionally<T>(null, d, this, f));
1040 >                else {
1041                      CompletableFuture<T> g = f.apply(x).toCompletableFuture();
1042                      if ((s = g.result) != null)
1043                          d.result = encodeRelay(s);
1044 <                    else {
1044 >                    else
1045                          g.unipush(new UniRelay<T,T>(d, g));
1042                    }
1043                } catch (Throwable ex) {
1044                    d.result = encodeThrowable(ex);
1046                  }
1046            }
1047            else
1048                d.internalComplete(r);
1049        }
1050        else
1051            try {
1052                e.execute(new UniComposeExceptionally<T>(null, d, this, f));
1047              } catch (Throwable ex) {
1048                  d.result = encodeThrowable(ex);
1049              }
# Line 1144 | Line 1138 | public class CompletableFuture<T> implem
1138          Object r, s; Throwable x;
1139          if ((r = result) == null)
1140              unipush(new UniCompose<T,V>(e, d, this, f));
1141 <        else if (e == null) {
1141 >        else {
1142              if (r instanceof AltResult) {
1143                  if ((x = ((AltResult)r).ex) != null) {
1144                      d.result = encodeThrowable(x, r);
# Line 1153 | Line 1147 | public class CompletableFuture<T> implem
1147                  r = null;
1148              }
1149              try {
1150 <                @SuppressWarnings("unchecked") T t = (T) r;
1151 <                CompletableFuture<V> g = f.apply(t).toCompletableFuture();
1158 <                if ((s = g.result) != null)
1159 <                    d.result = encodeRelay(s);
1150 >                if (e != null)
1151 >                    e.execute(new UniCompose<T,V>(null, d, this, f));
1152                  else {
1153 <                    g.unipush(new UniRelay<V,V>(d, g));
1153 >                    @SuppressWarnings("unchecked") T t = (T) r;
1154 >                    CompletableFuture<V> g = f.apply(t).toCompletableFuture();
1155 >                    if ((s = g.result) != null)
1156 >                        d.result = encodeRelay(s);
1157 >                    else
1158 >                        g.unipush(new UniRelay<V,V>(d, g));
1159                  }
1160              } catch (Throwable ex) {
1161                  d.result = encodeThrowable(ex);
1162              }
1163          }
1167        else
1168            try {
1169                e.execute(new UniCompose<T,V>(null, d, this, f));
1170            } catch (Throwable ex) {
1171                d.result = encodeThrowable(ex);
1172            }
1164          return d;
1165      }
1166  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines