375 |
|
} |
376 |
|
} |
377 |
|
static final class Noop implements Runnable { |
378 |
+ |
int invocationCount = 0; |
379 |
|
boolean ran; |
380 |
< |
public void run() { ran = true; } |
380 |
> |
public void run() { |
381 |
> |
invocationCount++; |
382 |
> |
ran = true; |
383 |
> |
} |
384 |
|
} |
385 |
|
|
386 |
|
static final class FailingSupplier implements Supplier<Integer> { |
958 |
|
|
959 |
|
f.complete(v1); |
960 |
|
checkIncomplete(h); |
961 |
< |
assertFalse(r.ran()); |
961 |
> |
assertEquals(r.invocationCount, 0); |
962 |
|
g.complete(v2); |
963 |
|
|
964 |
|
checkCompletedNormally(h, subtract(v1, v2)); |
965 |
|
checkCompletedNormally(f, v1); |
966 |
|
checkCompletedNormally(g, v2); |
967 |
+ |
assertEquals(r.invocationCount, 1); |
968 |
|
} |
969 |
|
} |
970 |
|
|
980 |
|
|
981 |
|
g.complete(v2); |
982 |
|
checkIncomplete(h); |
983 |
< |
assertFalse(r.ran()); |
983 |
> |
assertEquals(r.invocationCount, 0); |
984 |
|
f.complete(v1); |
985 |
|
|
986 |
|
checkCompletedNormally(h, subtract(v1, v2)); |
987 |
|
checkCompletedNormally(f, v1); |
988 |
|
checkCompletedNormally(g, v2); |
989 |
+ |
assertEquals(r.invocationCount, 1); |
990 |
|
} |
991 |
|
} |
992 |
|
|
1006 |
|
checkCompletedNormally(h, subtract(v1, v2)); |
1007 |
|
checkCompletedNormally(f, v1); |
1008 |
|
checkCompletedNormally(g, v2); |
1009 |
+ |
assertEquals(r.invocationCount, 1); |
1010 |
|
} |
1011 |
|
} |
1012 |
|
|
1026 |
|
checkCompletedNormally(h, subtract(v1, v2)); |
1027 |
|
checkCompletedNormally(f, v1); |
1028 |
|
checkCompletedNormally(g, v2); |
1029 |
+ |
assertEquals(r.invocationCount, 1); |
1030 |
|
} |
1031 |
|
} |
1032 |
|
|
1050 |
|
|
1051 |
|
checkCompletedWithWrappedCFException(h, ex); |
1052 |
|
checkCompletedWithWrappedCFException(f, ex); |
1053 |
< |
assertFalse(r.ran()); |
1053 |
> |
assertEquals(r.invocationCount, 0); |
1054 |
|
checkCompletedNormally(g, v1); |
1055 |
|
} |
1056 |
|
} |
1071 |
|
|
1072 |
|
checkCompletedWithWrappedCFException(h, ex); |
1073 |
|
checkCompletedWithWrappedCFException(g, ex); |
1074 |
< |
assertFalse(r.ran()); |
1074 |
> |
assertEquals(r.invocationCount, 0); |
1075 |
|
checkCompletedNormally(f, v1); |
1076 |
|
} |
1077 |
|
} |
1091 |
|
|
1092 |
|
checkCompletedWithWrappedCFException(h, ex); |
1093 |
|
checkCompletedWithWrappedCFException(g, ex); |
1094 |
< |
assertFalse(r.ran()); |
1094 |
> |
assertEquals(r.invocationCount, 0); |
1095 |
|
checkCompletedNormally(f, v1); |
1096 |
|
} |
1097 |
|
} |
1111 |
|
|
1112 |
|
checkCompletedWithWrappedCFException(h, ex); |
1113 |
|
checkCompletedWithWrappedCFException(f, ex); |
1114 |
< |
assertFalse(r.ran()); |
1114 |
> |
assertEquals(r.invocationCount, 0); |
1115 |
|
checkCompletedNormally(g, v1); |
1116 |
|
} |
1117 |
|
} |
1178 |
|
|
1179 |
|
checkCompletedWithWrappedCancellationException(h); |
1180 |
|
checkCancelled(f); |
1181 |
< |
assertFalse(r.ran()); |
1181 |
> |
assertEquals(r.invocationCount, 0); |
1182 |
|
checkCompletedNormally(g, v1); |
1183 |
|
} |
1184 |
|
} |
1199 |
|
|
1200 |
|
checkCompletedWithWrappedCancellationException(h); |
1201 |
|
checkCancelled(g); |
1202 |
< |
assertFalse(r.ran()); |
1202 |
> |
assertEquals(r.invocationCount, 0); |
1203 |
|
checkCompletedNormally(f, v1); |
1204 |
|
} |
1205 |
|
} |
1219 |
|
|
1220 |
|
checkCompletedWithWrappedCancellationException(h); |
1221 |
|
checkCancelled(g); |
1222 |
< |
assertFalse(r.ran()); |
1222 |
> |
assertEquals(r.invocationCount, 0); |
1223 |
|
checkCompletedNormally(f, v1); |
1224 |
|
} |
1225 |
|
} |
1239 |
|
|
1240 |
|
checkCompletedWithWrappedCancellationException(h); |
1241 |
|
checkCancelled(f); |
1242 |
< |
assertFalse(r.ran()); |
1242 |
> |
assertEquals(r.invocationCount, 0); |
1243 |
|
checkCompletedNormally(g, v1); |
1244 |
|
} |
1245 |
|
} |
1352 |
|
|
1353 |
|
checkCompletedWithWrappedCFException(h, ex); |
1354 |
|
checkCompletedWithWrappedCFException(f, ex); |
1355 |
< |
assertFalse(r.ran()); |
1355 |
> |
assertEquals(r.invocationCount, 0); |
1356 |
|
checkCompletedNormally(g, v1); |
1357 |
|
} |
1358 |
|
} |
1373 |
|
|
1374 |
|
checkCompletedWithWrappedCFException(h, ex); |
1375 |
|
checkCompletedWithWrappedCFException(g, ex); |
1376 |
< |
assertFalse(r.ran()); |
1376 |
> |
assertEquals(r.invocationCount, 0); |
1377 |
|
checkCompletedNormally(f, v1); |
1378 |
|
} |
1379 |
|
} |
1393 |
|
|
1394 |
|
checkCompletedWithWrappedCFException(h, ex); |
1395 |
|
checkCompletedWithWrappedCFException(g, ex); |
1396 |
< |
assertFalse(r.ran()); |
1396 |
> |
assertEquals(r.invocationCount, 0); |
1397 |
|
checkCompletedNormally(f, v1); |
1398 |
|
} |
1399 |
|
} |
1480 |
|
|
1481 |
|
checkCompletedWithWrappedCancellationException(h); |
1482 |
|
checkCancelled(f); |
1483 |
< |
assertFalse(r.ran()); |
1483 |
> |
assertEquals(r.invocationCount, 0); |
1484 |
|
checkCompletedNormally(g, v1); |
1485 |
|
} |
1486 |
|
} |
1501 |
|
|
1502 |
|
checkCompletedWithWrappedCancellationException(h); |
1503 |
|
checkCancelled(g); |
1504 |
< |
assertFalse(r.ran()); |
1504 |
> |
assertEquals(r.invocationCount, 0); |
1505 |
|
checkCompletedNormally(f, v1); |
1506 |
|
} |
1507 |
|
} |
1521 |
|
|
1522 |
|
checkCompletedWithWrappedCancellationException(h); |
1523 |
|
checkCancelled(g); |
1524 |
< |
assertFalse(r.ran()); |
1524 |
> |
assertEquals(r.invocationCount, 0); |
1525 |
|
checkCompletedNormally(f, v1); |
1526 |
|
} |
1527 |
|
} |
1541 |
|
|
1542 |
|
checkCompletedWithWrappedCancellationException(h); |
1543 |
|
checkCancelled(f); |
1544 |
< |
assertFalse(r.ran()); |
1544 |
> |
assertEquals(r.invocationCount, 0); |
1545 |
|
checkCompletedNormally(g, v1); |
1546 |
|
} |
1547 |
|
} |
1566 |
|
g.complete(v2); |
1567 |
|
|
1568 |
|
checkCompletedNormally(h, null); |
1569 |
< |
assertTrue(r.ran); |
1569 |
> |
assertEquals(r.invocationCount, 1); |
1570 |
|
checkCompletedNormally(f, v1); |
1571 |
|
checkCompletedNormally(g, v2); |
1572 |
|
} |
1588 |
|
f.complete(v1); |
1589 |
|
|
1590 |
|
checkCompletedNormally(h, null); |
1591 |
< |
assertTrue(r.ran); |
1591 |
> |
assertEquals(r.invocationCount, 1); |
1592 |
|
checkCompletedNormally(f, v1); |
1593 |
|
checkCompletedNormally(g, v2); |
1594 |
|
} |
1628 |
|
final CompletableFuture<Void> h = m.runAfterBoth(f, g, r); |
1629 |
|
|
1630 |
|
checkCompletedNormally(h, null); |
1631 |
< |
assertTrue(r.ran); |
1631 |
> |
assertEquals(r.invocationCount, 1); |
1632 |
|
checkCompletedNormally(f, v1); |
1633 |
|
checkCompletedNormally(g, v2); |
1634 |
|
} |
1654 |
|
|
1655 |
|
checkCompletedWithWrappedCFException(h, ex); |
1656 |
|
checkCompletedWithWrappedCFException(f, ex); |
1657 |
< |
assertFalse(r.ran); |
1657 |
> |
assertEquals(r.invocationCount, 0); |
1658 |
|
checkCompletedNormally(g, v1); |
1659 |
|
} |
1660 |
|
} |
1675 |
|
|
1676 |
|
checkCompletedWithWrappedCFException(h, ex); |
1677 |
|
checkCompletedWithWrappedCFException(g, ex); |
1678 |
< |
assertFalse(r.ran); |
1678 |
> |
assertEquals(r.invocationCount, 0); |
1679 |
|
checkCompletedNormally(f, v1); |
1680 |
|
} |
1681 |
|
} |
1695 |
|
|
1696 |
|
checkCompletedWithWrappedCFException(h, ex); |
1697 |
|
checkCompletedWithWrappedCFException(g, ex); |
1698 |
< |
assertFalse(r.ran); |
1698 |
> |
assertEquals(r.invocationCount, 0); |
1699 |
|
checkCompletedNormally(f, v1); |
1700 |
|
} |
1701 |
|
} |
1715 |
|
|
1716 |
|
checkCompletedWithWrappedCFException(h, ex); |
1717 |
|
checkCompletedWithWrappedCFException(f, ex); |
1718 |
< |
assertFalse(r.ran); |
1718 |
> |
assertEquals(r.invocationCount, 0); |
1719 |
|
checkCompletedNormally(g, v1); |
1720 |
|
} |
1721 |
|
} |
1782 |
|
|
1783 |
|
checkCompletedWithWrappedCancellationException(h); |
1784 |
|
checkCancelled(f); |
1785 |
< |
assertFalse(r.ran); |
1785 |
> |
assertEquals(r.invocationCount, 0); |
1786 |
|
checkCompletedNormally(g, v1); |
1787 |
|
} |
1788 |
|
} |
1803 |
|
|
1804 |
|
checkCompletedWithWrappedCancellationException(h); |
1805 |
|
checkCancelled(g); |
1806 |
< |
assertFalse(r.ran); |
1806 |
> |
assertEquals(r.invocationCount, 0); |
1807 |
|
checkCompletedNormally(f, v1); |
1808 |
|
} |
1809 |
|
} |
1823 |
|
|
1824 |
|
checkCompletedWithWrappedCancellationException(h); |
1825 |
|
checkCancelled(g); |
1826 |
< |
assertFalse(r.ran); |
1826 |
> |
assertEquals(r.invocationCount, 0); |
1827 |
|
checkCompletedNormally(f, v1); |
1828 |
|
} |
1829 |
|
} |
1843 |
|
|
1844 |
|
checkCompletedWithWrappedCancellationException(h); |
1845 |
|
checkCancelled(f); |
1846 |
< |
assertFalse(r.ran); |
1846 |
> |
assertEquals(r.invocationCount, 0); |
1847 |
|
checkCompletedNormally(g, v1); |
1848 |
|
} |
1849 |
|
} |
1910 |
|
// unspecified behavior |
1911 |
|
assertTrue(Objects.equals(h.join(), inc(v1)) || |
1912 |
|
Objects.equals(h.join(), inc(v2))); |
1913 |
+ |
assertEquals(r.invocationCount, 1); |
1914 |
|
} |
1915 |
|
} |
1916 |
|
|
1932 |
|
checkCompletedWithWrappedCFException(h, ex); |
1933 |
|
g.complete(v1); |
1934 |
|
|
1935 |
< |
assertFalse(r.ran()); |
1935 |
> |
assertEquals(r.invocationCount, 0); |
1936 |
|
checkCompletedNormally(g, v1); |
1937 |
|
checkCompletedWithWrappedCFException(f, ex); |
1938 |
|
checkCompletedWithWrappedCFException(h, ex); |
1953 |
|
checkCompletedWithWrappedCFException(h, ex); |
1954 |
|
f.complete(v1); |
1955 |
|
|
1956 |
< |
assertFalse(r.ran()); |
1956 |
> |
assertEquals(r.invocationCount, 0); |
1957 |
|
checkCompletedNormally(f, v1); |
1958 |
|
checkCompletedWithWrappedCFException(g, ex); |
1959 |
|
checkCompletedWithWrappedCFException(h, ex); |
1977 |
|
Integer v; |
1978 |
|
try { |
1979 |
|
assertEquals(h.join(), inc(v1)); |
1980 |
< |
assertTrue(r.ran()); |
1980 |
> |
assertEquals(r.invocationCount, 1); |
1981 |
|
} catch (CompletionException ok) { |
1982 |
|
checkCompletedWithWrappedCFException(h, ex); |
1983 |
< |
assertFalse(r.ran()); |
1983 |
> |
assertEquals(r.invocationCount, 0); |
1984 |
|
} |
1985 |
|
|
1986 |
|
checkCompletedWithWrappedCFException(g, ex); |
2005 |
|
Integer v; |
2006 |
|
try { |
2007 |
|
assertEquals(h.join(), inc(v1)); |
2008 |
< |
assertTrue(r.ran()); |
2008 |
> |
assertEquals(r.invocationCount, 1); |
2009 |
|
} catch (CompletionException ok) { |
2010 |
|
checkCompletedWithWrappedCFException(h, ex); |
2011 |
< |
assertFalse(r.ran()); |
2011 |
> |
assertEquals(r.invocationCount, 0); |
2012 |
|
} |
2013 |
|
|
2014 |
|
checkCompletedWithWrappedCFException(f, ex); |
2006 |
– |
assertFalse(r.ran()); |
2015 |
|
checkCompletedNormally(g, v1); |
2016 |
|
} |
2017 |
|
} |
2073 |
|
g.complete(v1); |
2074 |
|
|
2075 |
|
checkCancelled(f); |
2076 |
< |
assertFalse(r.ran()); |
2076 |
> |
assertEquals(r.invocationCount, 0); |
2077 |
|
checkCompletedNormally(g, v1); |
2078 |
|
checkCompletedWithWrappedCancellationException(h); |
2079 |
|
} |
2094 |
|
f.complete(v1); |
2095 |
|
|
2096 |
|
checkCancelled(g); |
2097 |
< |
assertFalse(r.ran()); |
2097 |
> |
assertEquals(r.invocationCount, 0); |
2098 |
|
checkCompletedNormally(f, v1); |
2099 |
|
checkCompletedWithWrappedCancellationException(h); |
2100 |
|
} |
2117 |
|
Integer v; |
2118 |
|
try { |
2119 |
|
assertEquals(h.join(), inc(v1)); |
2120 |
< |
assertTrue(r.ran()); |
2120 |
> |
assertEquals(r.invocationCount, 1); |
2121 |
|
} catch (CompletionException ok) { |
2122 |
|
checkCompletedWithWrappedCancellationException(h); |
2123 |
< |
assertFalse(r.ran()); |
2123 |
> |
assertEquals(r.invocationCount, 0); |
2124 |
|
} |
2125 |
|
|
2126 |
|
checkCancelled(g); |
2145 |
|
Integer v; |
2146 |
|
try { |
2147 |
|
assertEquals(h.join(), inc(v1)); |
2148 |
< |
assertTrue(r.ran()); |
2148 |
> |
assertEquals(r.invocationCount, 1); |
2149 |
|
} catch (CompletionException ok) { |
2150 |
|
checkCompletedWithWrappedCancellationException(h); |
2151 |
< |
assertFalse(r.ran()); |
2151 |
> |
assertEquals(r.invocationCount, 0); |
2152 |
|
} |
2153 |
|
|
2154 |
|
checkCancelled(f); |
2160 |
|
* acceptEither result completes normally after normal completion |
2161 |
|
* of either source |
2162 |
|
*/ |
2163 |
< |
public void testAcceptEither() { |
2164 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2165 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2166 |
< |
IncAction r = new IncAction(); |
2159 |
< |
CompletableFuture<Void> g = f.acceptEither(f2, r); |
2160 |
< |
f.complete(one); |
2161 |
< |
checkCompletedNormally(g, null); |
2162 |
< |
f2.complete(one); |
2163 |
< |
checkCompletedNormally(g, null); |
2164 |
< |
assertEquals(r.value, (Integer) 2); |
2163 |
> |
public void testAcceptEither_normalCompletion1() { |
2164 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2165 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2166 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2167 |
|
|
2168 |
< |
r = new IncAction(); |
2169 |
< |
f = new CompletableFuture<>(); |
2170 |
< |
f.complete(one); |
2171 |
< |
f2 = new CompletableFuture<>(); |
2172 |
< |
g = f.acceptEither(f2, r); |
2173 |
< |
checkCompletedNormally(g, null); |
2174 |
< |
assertEquals(r.value, (Integer) 2); |
2168 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2169 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2170 |
> |
final IncAction r = new IncAction(); |
2171 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2172 |
> |
|
2173 |
> |
f.complete(v1); |
2174 |
> |
checkCompletedNormally(h, null); |
2175 |
> |
assertEquals(r.value, inc(v1)); |
2176 |
> |
g.complete(v2); |
2177 |
> |
|
2178 |
> |
checkCompletedNormally(f, v1); |
2179 |
> |
checkCompletedNormally(g, v2); |
2180 |
> |
checkCompletedNormally(h, null); |
2181 |
> |
} |
2182 |
> |
} |
2183 |
> |
|
2184 |
> |
public void testAcceptEither_normalCompletion2() { |
2185 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2186 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2187 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2188 |
> |
|
2189 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2190 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2191 |
> |
final IncAction r = new IncAction(); |
2192 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2193 |
> |
|
2194 |
> |
g.complete(v2); |
2195 |
> |
checkCompletedNormally(h, null); |
2196 |
> |
assertEquals(r.value, inc(v2)); |
2197 |
> |
f.complete(v1); |
2198 |
> |
|
2199 |
> |
checkCompletedNormally(f, v1); |
2200 |
> |
checkCompletedNormally(g, v2); |
2201 |
> |
checkCompletedNormally(h, null); |
2202 |
> |
} |
2203 |
> |
} |
2204 |
> |
public void testAcceptEither_normalCompletion3() { |
2205 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2206 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2207 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2208 |
> |
|
2209 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2210 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2211 |
> |
final IncAction r = new IncAction(); |
2212 |
> |
|
2213 |
> |
f.complete(v1); |
2214 |
> |
g.complete(v2); |
2215 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2216 |
> |
|
2217 |
> |
checkCompletedNormally(h, null); |
2218 |
> |
checkCompletedNormally(f, v1); |
2219 |
> |
checkCompletedNormally(g, v2); |
2220 |
> |
|
2221 |
> |
// unspecified behavior |
2222 |
> |
assertTrue(Objects.equals(r.value, inc(v1)) || |
2223 |
> |
Objects.equals(r.value, inc(v2))); |
2224 |
> |
} |
2225 |
|
} |
2226 |
|
|
2227 |
|
/** |
2228 |
|
* acceptEither result completes exceptionally after exceptional |
2229 |
|
* completion of either source |
2230 |
|
*/ |
2231 |
< |
public void testAcceptEither2() { |
2232 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2233 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2182 |
< |
IncAction r = new IncAction(); |
2183 |
< |
CompletableFuture<Void> g = f.acceptEither(f2, r); |
2184 |
< |
f.completeExceptionally(new CFException()); |
2185 |
< |
f2.complete(one); |
2186 |
< |
checkCompletedWithWrappedCFException(g); |
2231 |
> |
public void testAcceptEither_exceptionalCompletion1() { |
2232 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2233 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2234 |
|
|
2235 |
< |
r = new IncAction(); |
2236 |
< |
f = new CompletableFuture<>(); |
2237 |
< |
f2 = new CompletableFuture<>(); |
2238 |
< |
f2.completeExceptionally(new CFException()); |
2239 |
< |
g = f.acceptEither(f2, r); |
2240 |
< |
checkCompletedWithWrappedCFException(g); |
2235 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2236 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2237 |
> |
final IncAction r = new IncAction(); |
2238 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2239 |
> |
final CFException ex = new CFException(); |
2240 |
> |
|
2241 |
> |
f.completeExceptionally(ex); |
2242 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2243 |
> |
g.complete(v1); |
2244 |
> |
|
2245 |
> |
assertEquals(r.invocationCount, 0); |
2246 |
> |
checkCompletedNormally(g, v1); |
2247 |
> |
checkCompletedWithWrappedCFException(f, ex); |
2248 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2249 |
> |
} |
2250 |
> |
} |
2251 |
> |
|
2252 |
> |
public void testAcceptEither_exceptionalCompletion2() { |
2253 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2254 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2255 |
> |
|
2256 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2257 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2258 |
> |
final IncAction r = new IncAction(); |
2259 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2260 |
> |
final CFException ex = new CFException(); |
2261 |
> |
|
2262 |
> |
g.completeExceptionally(ex); |
2263 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2264 |
> |
f.complete(v1); |
2265 |
> |
|
2266 |
> |
assertEquals(r.invocationCount, 0); |
2267 |
> |
checkCompletedNormally(f, v1); |
2268 |
> |
checkCompletedWithWrappedCFException(g, ex); |
2269 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2270 |
> |
} |
2271 |
> |
} |
2272 |
> |
|
2273 |
> |
public void testAcceptEither_exceptionalCompletion3() { |
2274 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2275 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2276 |
> |
|
2277 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2278 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2279 |
> |
final IncAction r = new IncAction(); |
2280 |
> |
final CFException ex = new CFException(); |
2281 |
> |
|
2282 |
> |
g.completeExceptionally(ex); |
2283 |
> |
f.complete(v1); |
2284 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2285 |
> |
|
2286 |
> |
// unspecified behavior |
2287 |
> |
Integer v; |
2288 |
> |
try { |
2289 |
> |
assertEquals(h.join(), null); |
2290 |
> |
assertEquals(r.invocationCount, 1); |
2291 |
> |
assertEquals(inc(v1), r.value); |
2292 |
> |
} catch (CompletionException ok) { |
2293 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2294 |
> |
assertEquals(r.invocationCount, 0); |
2295 |
> |
} |
2296 |
> |
|
2297 |
> |
checkCompletedWithWrappedCFException(g, ex); |
2298 |
> |
checkCompletedNormally(f, v1); |
2299 |
> |
} |
2300 |
> |
} |
2301 |
> |
|
2302 |
> |
public void testAcceptEither_exceptionalCompletion4() { |
2303 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2304 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2305 |
> |
|
2306 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2307 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2308 |
> |
final IncAction r = new IncAction(); |
2309 |
> |
final CFException ex = new CFException(); |
2310 |
> |
|
2311 |
> |
f.completeExceptionally(ex); |
2312 |
> |
g.complete(v1); |
2313 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2314 |
> |
|
2315 |
> |
// unspecified behavior |
2316 |
> |
Integer v; |
2317 |
> |
try { |
2318 |
> |
assertEquals(h.join(), null); |
2319 |
> |
assertEquals(r.invocationCount, 1); |
2320 |
> |
assertEquals(inc(v1), r.value); |
2321 |
> |
} catch (CompletionException ok) { |
2322 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2323 |
> |
assertEquals(r.invocationCount, 0); |
2324 |
> |
} |
2325 |
> |
|
2326 |
> |
checkCompletedWithWrappedCFException(f, ex); |
2327 |
> |
checkCompletedNormally(g, v1); |
2328 |
> |
} |
2329 |
|
} |
2330 |
|
|
2331 |
|
/** |
2332 |
|
* acceptEither result completes exceptionally if action does |
2333 |
|
*/ |
2334 |
< |
public void testAcceptEither3() { |
2335 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2336 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2337 |
< |
FailingConsumer r = new FailingConsumer(); |
2338 |
< |
CompletableFuture<Void> g = f.acceptEither(f2, r); |
2339 |
< |
f2.complete(two); |
2340 |
< |
checkCompletedWithWrappedCFException(g); |
2334 |
> |
public void testAcceptEither_actionFailed1() { |
2335 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2336 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2337 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2338 |
> |
|
2339 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2340 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2341 |
> |
final FailingConsumer r = new FailingConsumer(); |
2342 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2343 |
> |
|
2344 |
> |
f.complete(v1); |
2345 |
> |
checkCompletedWithWrappedCFException(h); |
2346 |
> |
g.complete(v2); |
2347 |
> |
checkCompletedNormally(f, v1); |
2348 |
> |
checkCompletedNormally(g, v2); |
2349 |
> |
} |
2350 |
> |
} |
2351 |
> |
|
2352 |
> |
public void testAcceptEither_actionFailed2() { |
2353 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2354 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2355 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2356 |
> |
|
2357 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2358 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2359 |
> |
final FailingConsumer r = new FailingConsumer(); |
2360 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2361 |
> |
|
2362 |
> |
g.complete(v2); |
2363 |
> |
checkCompletedWithWrappedCFException(h); |
2364 |
> |
f.complete(v1); |
2365 |
> |
checkCompletedNormally(f, v1); |
2366 |
> |
checkCompletedNormally(g, v2); |
2367 |
> |
} |
2368 |
|
} |
2369 |
|
|
2370 |
|
/** |
2371 |
|
* acceptEither result completes exceptionally if either source cancelled |
2372 |
|
*/ |
2373 |
< |
public void testAcceptEither4() { |
2374 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2375 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2376 |
< |
IncAction r = new IncAction(); |
2377 |
< |
CompletableFuture<Void> g = f.acceptEither(f2, r); |
2378 |
< |
assertTrue(f.cancel(true)); |
2379 |
< |
checkCompletedWithWrappedCancellationException(g); |
2380 |
< |
f = new CompletableFuture<>(); |
2381 |
< |
f2 = new CompletableFuture<>(); |
2382 |
< |
assertTrue(f2.cancel(true)); |
2383 |
< |
checkCompletedWithWrappedCancellationException(g); |
2373 |
> |
public void testAcceptEither_sourceCancelled1() { |
2374 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2375 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2376 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2377 |
> |
|
2378 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2379 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2380 |
> |
final IncAction r = new IncAction(); |
2381 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2382 |
> |
|
2383 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
2384 |
> |
checkCompletedWithWrappedCancellationException(h); |
2385 |
> |
g.complete(v1); |
2386 |
> |
|
2387 |
> |
checkCancelled(f); |
2388 |
> |
assertEquals(r.invocationCount, 0); |
2389 |
> |
checkCompletedNormally(g, v1); |
2390 |
> |
checkCompletedWithWrappedCancellationException(h); |
2391 |
> |
} |
2392 |
> |
} |
2393 |
> |
|
2394 |
> |
public void testAcceptEither_sourceCancelled2() { |
2395 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2396 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2397 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2398 |
> |
|
2399 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2400 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2401 |
> |
final IncAction r = new IncAction(); |
2402 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2403 |
> |
|
2404 |
> |
assertTrue(g.cancel(mayInterruptIfRunning)); |
2405 |
> |
checkCompletedWithWrappedCancellationException(h); |
2406 |
> |
f.complete(v1); |
2407 |
> |
|
2408 |
> |
checkCancelled(g); |
2409 |
> |
assertEquals(r.invocationCount, 0); |
2410 |
> |
checkCompletedNormally(f, v1); |
2411 |
> |
checkCompletedWithWrappedCancellationException(h); |
2412 |
> |
} |
2413 |
> |
} |
2414 |
> |
|
2415 |
> |
public void testAcceptEither_sourceCancelled3() { |
2416 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2417 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2418 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2419 |
> |
|
2420 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2421 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2422 |
> |
final IncAction r = new IncAction(); |
2423 |
> |
|
2424 |
> |
assertTrue(g.cancel(mayInterruptIfRunning)); |
2425 |
> |
f.complete(v1); |
2426 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2427 |
> |
|
2428 |
> |
// unspecified behavior |
2429 |
> |
Integer v; |
2430 |
> |
try { |
2431 |
> |
assertEquals(h.join(), null); |
2432 |
> |
assertEquals(r.invocationCount, 1); |
2433 |
> |
assertEquals(inc(v1), r.value); |
2434 |
> |
} catch (CompletionException ok) { |
2435 |
> |
checkCompletedWithWrappedCancellationException(h); |
2436 |
> |
assertEquals(r.invocationCount, 0); |
2437 |
> |
} |
2438 |
> |
|
2439 |
> |
checkCancelled(g); |
2440 |
> |
checkCompletedNormally(f, v1); |
2441 |
> |
} |
2442 |
> |
} |
2443 |
> |
|
2444 |
> |
public void testAcceptEither_sourceCancelled4() { |
2445 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2446 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2447 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2448 |
> |
|
2449 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2450 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2451 |
> |
final IncAction r = new IncAction(); |
2452 |
> |
|
2453 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
2454 |
> |
g.complete(v1); |
2455 |
> |
final CompletableFuture<Void> h = m.acceptEither(f, g, r); |
2456 |
> |
|
2457 |
> |
// unspecified behavior |
2458 |
> |
Integer v; |
2459 |
> |
try { |
2460 |
> |
assertEquals(h.join(), null); |
2461 |
> |
assertEquals(r.invocationCount, 1); |
2462 |
> |
assertEquals(inc(v1), r.value); |
2463 |
> |
} catch (CompletionException ok) { |
2464 |
> |
checkCompletedWithWrappedCancellationException(h); |
2465 |
> |
assertEquals(r.invocationCount, 0); |
2466 |
> |
} |
2467 |
> |
|
2468 |
> |
checkCancelled(f); |
2469 |
> |
checkCompletedNormally(g, v1); |
2470 |
> |
} |
2471 |
|
} |
2472 |
|
|
2473 |
|
/** |
2474 |
|
* runAfterEither result completes normally after normal completion |
2475 |
|
* of either source |
2476 |
|
*/ |
2477 |
< |
public void testRunAfterEither() { |
2478 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2479 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2480 |
< |
Noop r = new Noop(); |
2232 |
< |
CompletableFuture<Void> g = f.runAfterEither(f2, r); |
2233 |
< |
f.complete(one); |
2234 |
< |
checkCompletedNormally(g, null); |
2235 |
< |
f2.complete(one); |
2236 |
< |
checkCompletedNormally(g, null); |
2237 |
< |
assertTrue(r.ran); |
2477 |
> |
public void testRunAfterEither_normalCompletion1() { |
2478 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2479 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2480 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2481 |
|
|
2482 |
< |
r = new Noop(); |
2483 |
< |
f = new CompletableFuture<>(); |
2484 |
< |
f.complete(one); |
2485 |
< |
f2 = new CompletableFuture<>(); |
2486 |
< |
g = f.runAfterEither(f2, r); |
2487 |
< |
checkCompletedNormally(g, null); |
2488 |
< |
assertTrue(r.ran); |
2482 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2483 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2484 |
> |
final Noop r = new Noop(); |
2485 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2486 |
> |
|
2487 |
> |
f.complete(v1); |
2488 |
> |
checkCompletedNormally(h, null); |
2489 |
> |
assertEquals(r.invocationCount, 1); |
2490 |
> |
g.complete(v2); |
2491 |
> |
|
2492 |
> |
checkCompletedNormally(f, v1); |
2493 |
> |
checkCompletedNormally(g, v2); |
2494 |
> |
checkCompletedNormally(h, null); |
2495 |
> |
assertEquals(r.invocationCount, 1); |
2496 |
> |
} |
2497 |
> |
} |
2498 |
> |
|
2499 |
> |
public void testRunAfterEither_normalCompletion2() { |
2500 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2501 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2502 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2503 |
> |
|
2504 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2505 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2506 |
> |
final Noop r = new Noop(); |
2507 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2508 |
> |
|
2509 |
> |
g.complete(v2); |
2510 |
> |
checkCompletedNormally(h, null); |
2511 |
> |
assertEquals(r.invocationCount, 1); |
2512 |
> |
f.complete(v1); |
2513 |
> |
|
2514 |
> |
checkCompletedNormally(f, v1); |
2515 |
> |
checkCompletedNormally(g, v2); |
2516 |
> |
checkCompletedNormally(h, null); |
2517 |
> |
assertEquals(r.invocationCount, 1); |
2518 |
> |
} |
2519 |
> |
} |
2520 |
> |
public void testRunAfterEither_normalCompletion3() { |
2521 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2522 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2523 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2524 |
> |
|
2525 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2526 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2527 |
> |
final Noop r = new Noop(); |
2528 |
> |
|
2529 |
> |
f.complete(v1); |
2530 |
> |
g.complete(v2); |
2531 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2532 |
> |
|
2533 |
> |
checkCompletedNormally(h, null); |
2534 |
> |
checkCompletedNormally(f, v1); |
2535 |
> |
checkCompletedNormally(g, v2); |
2536 |
> |
assertEquals(r.invocationCount, 1); |
2537 |
> |
} |
2538 |
|
} |
2539 |
|
|
2540 |
|
/** |
2541 |
|
* runAfterEither result completes exceptionally after exceptional |
2542 |
|
* completion of either source |
2543 |
|
*/ |
2544 |
< |
public void testRunAfterEither2() { |
2545 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2546 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2255 |
< |
Noop r = new Noop(); |
2256 |
< |
CompletableFuture<Void> g = f.runAfterEither(f2, r); |
2257 |
< |
f.completeExceptionally(new CFException()); |
2258 |
< |
f2.complete(one); |
2259 |
< |
checkCompletedWithWrappedCFException(g); |
2544 |
> |
public void testRunAfterEither_exceptionalCompletion1() { |
2545 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2546 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2547 |
|
|
2548 |
< |
r = new Noop(); |
2549 |
< |
f = new CompletableFuture<>(); |
2550 |
< |
f2 = new CompletableFuture<>(); |
2551 |
< |
f2.completeExceptionally(new CFException()); |
2552 |
< |
g = f.runAfterEither(f2, r); |
2553 |
< |
checkCompletedWithWrappedCFException(g); |
2548 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2549 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2550 |
> |
final Noop r = new Noop(); |
2551 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2552 |
> |
final CFException ex = new CFException(); |
2553 |
> |
|
2554 |
> |
f.completeExceptionally(ex); |
2555 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2556 |
> |
g.complete(v1); |
2557 |
> |
|
2558 |
> |
assertEquals(r.invocationCount, 0); |
2559 |
> |
checkCompletedNormally(g, v1); |
2560 |
> |
checkCompletedWithWrappedCFException(f, ex); |
2561 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2562 |
> |
} |
2563 |
> |
} |
2564 |
> |
|
2565 |
> |
public void testRunAfterEither_exceptionalCompletion2() { |
2566 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2567 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2568 |
> |
|
2569 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2570 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2571 |
> |
final Noop r = new Noop(); |
2572 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2573 |
> |
final CFException ex = new CFException(); |
2574 |
> |
|
2575 |
> |
g.completeExceptionally(ex); |
2576 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2577 |
> |
f.complete(v1); |
2578 |
> |
|
2579 |
> |
assertEquals(r.invocationCount, 0); |
2580 |
> |
checkCompletedNormally(f, v1); |
2581 |
> |
checkCompletedWithWrappedCFException(g, ex); |
2582 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2583 |
> |
} |
2584 |
> |
} |
2585 |
> |
|
2586 |
> |
public void testRunAfterEither_exceptionalCompletion3() { |
2587 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2588 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2589 |
> |
|
2590 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2591 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2592 |
> |
final Noop r = new Noop(); |
2593 |
> |
final CFException ex = new CFException(); |
2594 |
> |
|
2595 |
> |
g.completeExceptionally(ex); |
2596 |
> |
f.complete(v1); |
2597 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2598 |
> |
|
2599 |
> |
// unspecified behavior |
2600 |
> |
Integer v; |
2601 |
> |
try { |
2602 |
> |
assertEquals(h.join(), null); |
2603 |
> |
assertEquals(r.invocationCount, 1); |
2604 |
> |
} catch (CompletionException ok) { |
2605 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2606 |
> |
assertEquals(r.invocationCount, 0); |
2607 |
> |
} |
2608 |
> |
|
2609 |
> |
checkCompletedWithWrappedCFException(g, ex); |
2610 |
> |
checkCompletedNormally(f, v1); |
2611 |
> |
} |
2612 |
> |
} |
2613 |
> |
|
2614 |
> |
public void testRunAfterEither_exceptionalCompletion4() { |
2615 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2616 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2617 |
> |
|
2618 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2619 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2620 |
> |
final Noop r = new Noop(); |
2621 |
> |
final CFException ex = new CFException(); |
2622 |
> |
|
2623 |
> |
f.completeExceptionally(ex); |
2624 |
> |
g.complete(v1); |
2625 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2626 |
> |
|
2627 |
> |
// unspecified behavior |
2628 |
> |
Integer v; |
2629 |
> |
try { |
2630 |
> |
assertEquals(h.join(), null); |
2631 |
> |
assertEquals(r.invocationCount, 1); |
2632 |
> |
} catch (CompletionException ok) { |
2633 |
> |
checkCompletedWithWrappedCFException(h, ex); |
2634 |
> |
assertEquals(r.invocationCount, 0); |
2635 |
> |
} |
2636 |
> |
|
2637 |
> |
checkCompletedWithWrappedCFException(f, ex); |
2638 |
> |
checkCompletedNormally(g, v1); |
2639 |
> |
} |
2640 |
|
} |
2641 |
|
|
2642 |
|
/** |
2643 |
|
* runAfterEither result completes exceptionally if action does |
2644 |
|
*/ |
2645 |
< |
public void testRunAfterEither3() { |
2646 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2647 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2648 |
< |
FailingNoop r = new FailingNoop(); |
2649 |
< |
CompletableFuture<Void> g = f.runAfterEither(f2, r); |
2650 |
< |
f2.complete(two); |
2651 |
< |
checkCompletedWithWrappedCFException(g); |
2645 |
> |
public void testRunAfterEither_actionFailed1() { |
2646 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2647 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2648 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2649 |
> |
|
2650 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2651 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2652 |
> |
final FailingNoop r = new FailingNoop(); |
2653 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2654 |
> |
|
2655 |
> |
f.complete(v1); |
2656 |
> |
checkCompletedWithWrappedCFException(h); |
2657 |
> |
g.complete(v2); |
2658 |
> |
checkCompletedNormally(f, v1); |
2659 |
> |
checkCompletedNormally(g, v2); |
2660 |
> |
} |
2661 |
> |
} |
2662 |
> |
|
2663 |
> |
public void testRunAfterEither_actionFailed2() { |
2664 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2665 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
2666 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
2667 |
> |
|
2668 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2669 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2670 |
> |
final FailingNoop r = new FailingNoop(); |
2671 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2672 |
> |
|
2673 |
> |
g.complete(v2); |
2674 |
> |
checkCompletedWithWrappedCFException(h); |
2675 |
> |
f.complete(v1); |
2676 |
> |
checkCompletedNormally(f, v1); |
2677 |
> |
checkCompletedNormally(g, v2); |
2678 |
> |
} |
2679 |
|
} |
2680 |
|
|
2681 |
|
/** |
2682 |
|
* runAfterEither result completes exceptionally if either source cancelled |
2683 |
|
*/ |
2684 |
< |
public void testRunAfterEither4() { |
2685 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2686 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2687 |
< |
Noop r = new Noop(); |
2688 |
< |
CompletableFuture<Void> g = f.runAfterEither(f2, r); |
2689 |
< |
assertTrue(f.cancel(true)); |
2690 |
< |
checkCompletedWithWrappedCancellationException(g); |
2691 |
< |
f = new CompletableFuture<>(); |
2692 |
< |
f2 = new CompletableFuture<>(); |
2693 |
< |
assertTrue(f2.cancel(true)); |
2694 |
< |
checkCompletedWithWrappedCancellationException(g); |
2684 |
> |
public void testRunAfterEither_sourceCancelled1() { |
2685 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2686 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2687 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2688 |
> |
|
2689 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2690 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2691 |
> |
final Noop r = new Noop(); |
2692 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2693 |
> |
|
2694 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
2695 |
> |
checkCompletedWithWrappedCancellationException(h); |
2696 |
> |
g.complete(v1); |
2697 |
> |
|
2698 |
> |
checkCancelled(f); |
2699 |
> |
assertEquals(r.invocationCount, 0); |
2700 |
> |
checkCompletedNormally(g, v1); |
2701 |
> |
checkCompletedWithWrappedCancellationException(h); |
2702 |
> |
} |
2703 |
> |
} |
2704 |
> |
|
2705 |
> |
public void testRunAfterEither_sourceCancelled2() { |
2706 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2707 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2708 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2709 |
> |
|
2710 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2711 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2712 |
> |
final Noop r = new Noop(); |
2713 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2714 |
> |
|
2715 |
> |
assertTrue(g.cancel(mayInterruptIfRunning)); |
2716 |
> |
checkCompletedWithWrappedCancellationException(h); |
2717 |
> |
f.complete(v1); |
2718 |
> |
|
2719 |
> |
checkCancelled(g); |
2720 |
> |
assertEquals(r.invocationCount, 0); |
2721 |
> |
checkCompletedNormally(f, v1); |
2722 |
> |
checkCompletedWithWrappedCancellationException(h); |
2723 |
> |
} |
2724 |
> |
} |
2725 |
> |
|
2726 |
> |
public void testRunAfterEither_sourceCancelled3() { |
2727 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2728 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2729 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2730 |
> |
|
2731 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2732 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2733 |
> |
final Noop r = new Noop(); |
2734 |
> |
|
2735 |
> |
assertTrue(g.cancel(mayInterruptIfRunning)); |
2736 |
> |
f.complete(v1); |
2737 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2738 |
> |
|
2739 |
> |
// unspecified behavior |
2740 |
> |
Integer v; |
2741 |
> |
try { |
2742 |
> |
assertEquals(h.join(), null); |
2743 |
> |
assertEquals(r.invocationCount, 1); |
2744 |
> |
} catch (CompletionException ok) { |
2745 |
> |
checkCompletedWithWrappedCancellationException(h); |
2746 |
> |
assertEquals(r.invocationCount, 0); |
2747 |
> |
} |
2748 |
> |
|
2749 |
> |
checkCancelled(g); |
2750 |
> |
checkCompletedNormally(f, v1); |
2751 |
> |
} |
2752 |
> |
} |
2753 |
> |
|
2754 |
> |
public void testRunAfterEither_sourceCancelled4() { |
2755 |
> |
for (ExecutionMode m : ExecutionMode.values()) |
2756 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
2757 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
2758 |
> |
|
2759 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
2760 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
2761 |
> |
final Noop r = new Noop(); |
2762 |
> |
|
2763 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
2764 |
> |
g.complete(v1); |
2765 |
> |
final CompletableFuture<Void> h = m.runAfterEither(f, g, r); |
2766 |
> |
|
2767 |
> |
// unspecified behavior |
2768 |
> |
Integer v; |
2769 |
> |
try { |
2770 |
> |
assertEquals(h.join(), null); |
2771 |
> |
assertEquals(r.invocationCount, 1); |
2772 |
> |
} catch (CompletionException ok) { |
2773 |
> |
checkCompletedWithWrappedCancellationException(h); |
2774 |
> |
assertEquals(r.invocationCount, 0); |
2775 |
> |
} |
2776 |
> |
|
2777 |
> |
checkCancelled(f); |
2778 |
> |
checkCompletedNormally(g, v1); |
2779 |
> |
} |
2780 |
|
} |
2781 |
|
|
2782 |
|
/** |
3002 |
|
} |
3003 |
|
|
3004 |
|
/** |
2520 |
– |
* acceptEitherAsync result completes normally after normal |
2521 |
– |
* completion of sources |
2522 |
– |
*/ |
2523 |
– |
public void testAcceptEitherAsync() { |
2524 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2525 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2526 |
– |
IncAction r = new IncAction(); |
2527 |
– |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r); |
2528 |
– |
f.complete(one); |
2529 |
– |
checkCompletedNormally(g, null); |
2530 |
– |
assertEquals(r.value, (Integer) 2); |
2531 |
– |
|
2532 |
– |
r = new IncAction(); |
2533 |
– |
f = new CompletableFuture<>(); |
2534 |
– |
f.complete(one); |
2535 |
– |
f2 = new CompletableFuture<>(); |
2536 |
– |
g = f.acceptEitherAsync(f2, r); |
2537 |
– |
checkCompletedNormally(g, null); |
2538 |
– |
assertEquals(r.value, (Integer) 2); |
2539 |
– |
} |
2540 |
– |
|
2541 |
– |
/** |
2542 |
– |
* acceptEitherAsync result completes exceptionally after exceptional |
2543 |
– |
* completion of source |
2544 |
– |
*/ |
2545 |
– |
public void testAcceptEitherAsync2() { |
2546 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2547 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2548 |
– |
IncAction r = new IncAction(); |
2549 |
– |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r); |
2550 |
– |
f.completeExceptionally(new CFException()); |
2551 |
– |
checkCompletedWithWrappedCFException(g); |
2552 |
– |
|
2553 |
– |
r = new IncAction(); |
2554 |
– |
f = new CompletableFuture<>(); |
2555 |
– |
f2 = new CompletableFuture<>(); |
2556 |
– |
f2.completeExceptionally(new CFException()); |
2557 |
– |
g = f.acceptEitherAsync(f2, r); |
2558 |
– |
f.complete(one); |
2559 |
– |
checkCompletedWithWrappedCFException(g); |
2560 |
– |
} |
2561 |
– |
|
2562 |
– |
/** |
2563 |
– |
* acceptEitherAsync result completes exceptionally if action does |
2564 |
– |
*/ |
2565 |
– |
public void testAcceptEitherAsync3() { |
2566 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2567 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2568 |
– |
FailingConsumer r = new FailingConsumer(); |
2569 |
– |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r); |
2570 |
– |
f.complete(one); |
2571 |
– |
checkCompletedWithWrappedCFException(g); |
2572 |
– |
} |
2573 |
– |
|
2574 |
– |
/** |
2575 |
– |
* acceptEitherAsync result completes exceptionally if either |
2576 |
– |
* source cancelled |
2577 |
– |
*/ |
2578 |
– |
public void testAcceptEitherAsync4() { |
2579 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2580 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2581 |
– |
IncAction r = new IncAction(); |
2582 |
– |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r); |
2583 |
– |
assertTrue(f.cancel(true)); |
2584 |
– |
checkCompletedWithWrappedCancellationException(g); |
2585 |
– |
|
2586 |
– |
r = new IncAction(); |
2587 |
– |
f = new CompletableFuture<>(); |
2588 |
– |
f2 = new CompletableFuture<>(); |
2589 |
– |
assertTrue(f2.cancel(true)); |
2590 |
– |
g = f.acceptEitherAsync(f2, r); |
2591 |
– |
checkCompletedWithWrappedCancellationException(g); |
2592 |
– |
} |
2593 |
– |
|
2594 |
– |
/** |
2595 |
– |
* runAfterEitherAsync result completes normally after normal |
2596 |
– |
* completion of sources |
2597 |
– |
*/ |
2598 |
– |
public void testRunAfterEitherAsync() { |
2599 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2600 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2601 |
– |
Noop r = new Noop(); |
2602 |
– |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r); |
2603 |
– |
f.complete(one); |
2604 |
– |
checkCompletedNormally(g, null); |
2605 |
– |
assertTrue(r.ran); |
2606 |
– |
|
2607 |
– |
r = new Noop(); |
2608 |
– |
f = new CompletableFuture<>(); |
2609 |
– |
f.complete(one); |
2610 |
– |
f2 = new CompletableFuture<>(); |
2611 |
– |
g = f.runAfterEitherAsync(f2, r); |
2612 |
– |
checkCompletedNormally(g, null); |
2613 |
– |
assertTrue(r.ran); |
2614 |
– |
} |
2615 |
– |
|
2616 |
– |
/** |
2617 |
– |
* runAfterEitherAsync result completes exceptionally after exceptional |
2618 |
– |
* completion of source |
2619 |
– |
*/ |
2620 |
– |
public void testRunAfterEitherAsync2() { |
2621 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2622 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2623 |
– |
Noop r = new Noop(); |
2624 |
– |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r); |
2625 |
– |
f.completeExceptionally(new CFException()); |
2626 |
– |
checkCompletedWithWrappedCFException(g); |
2627 |
– |
|
2628 |
– |
r = new Noop(); |
2629 |
– |
f = new CompletableFuture<>(); |
2630 |
– |
f2 = new CompletableFuture<>(); |
2631 |
– |
f2.completeExceptionally(new CFException()); |
2632 |
– |
g = f.runAfterEitherAsync(f2, r); |
2633 |
– |
f.complete(one); |
2634 |
– |
checkCompletedWithWrappedCFException(g); |
2635 |
– |
} |
2636 |
– |
|
2637 |
– |
/** |
2638 |
– |
* runAfterEitherAsync result completes exceptionally if action does |
2639 |
– |
*/ |
2640 |
– |
public void testRunAfterEitherAsync3() { |
2641 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2642 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2643 |
– |
FailingNoop r = new FailingNoop(); |
2644 |
– |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r); |
2645 |
– |
f.complete(one); |
2646 |
– |
checkCompletedWithWrappedCFException(g); |
2647 |
– |
} |
2648 |
– |
|
2649 |
– |
/** |
2650 |
– |
* runAfterEitherAsync result completes exceptionally if either |
2651 |
– |
* source cancelled |
2652 |
– |
*/ |
2653 |
– |
public void testRunAfterEitherAsync4() { |
2654 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2655 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2656 |
– |
Noop r = new Noop(); |
2657 |
– |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r); |
2658 |
– |
assertTrue(f.cancel(true)); |
2659 |
– |
checkCompletedWithWrappedCancellationException(g); |
2660 |
– |
|
2661 |
– |
r = new Noop(); |
2662 |
– |
f = new CompletableFuture<>(); |
2663 |
– |
f2 = new CompletableFuture<>(); |
2664 |
– |
assertTrue(f2.cancel(true)); |
2665 |
– |
g = f.runAfterEitherAsync(f2, r); |
2666 |
– |
checkCompletedWithWrappedCancellationException(g); |
2667 |
– |
} |
2668 |
– |
|
2669 |
– |
/** |
3005 |
|
* thenComposeAsync result completes normally after normal |
3006 |
|
* completion of source |
3007 |
|
*/ |
3224 |
|
checkCompletedWithWrappedCancellationException(g); |
3225 |
|
} |
3226 |
|
|
2892 |
– |
/** |
2893 |
– |
* acceptEitherAsync result completes normally after normal |
2894 |
– |
* completion of sources |
2895 |
– |
*/ |
2896 |
– |
public void testAcceptEitherAsyncE() { |
2897 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2898 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2899 |
– |
IncAction r = new IncAction(); |
2900 |
– |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2901 |
– |
f.complete(one); |
2902 |
– |
checkCompletedNormally(g, null); |
2903 |
– |
assertEquals(r.value, (Integer) 2); |
2904 |
– |
|
2905 |
– |
r = new IncAction(); |
2906 |
– |
f = new CompletableFuture<>(); |
2907 |
– |
f.complete(one); |
2908 |
– |
f2 = new CompletableFuture<>(); |
2909 |
– |
g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2910 |
– |
checkCompletedNormally(g, null); |
2911 |
– |
assertEquals(r.value, (Integer) 2); |
2912 |
– |
} |
2913 |
– |
|
2914 |
– |
/** |
2915 |
– |
* acceptEitherAsync result completes exceptionally after exceptional |
2916 |
– |
* completion of source |
2917 |
– |
*/ |
2918 |
– |
public void testAcceptEitherAsync2E() { |
2919 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2920 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2921 |
– |
IncAction r = new IncAction(); |
2922 |
– |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2923 |
– |
f.completeExceptionally(new CFException()); |
2924 |
– |
checkCompletedWithWrappedCFException(g); |
2925 |
– |
|
2926 |
– |
r = new IncAction(); |
2927 |
– |
f = new CompletableFuture<>(); |
2928 |
– |
f2 = new CompletableFuture<>(); |
2929 |
– |
f2.completeExceptionally(new CFException()); |
2930 |
– |
g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2931 |
– |
f.complete(one); |
2932 |
– |
checkCompletedWithWrappedCFException(g); |
2933 |
– |
} |
2934 |
– |
|
2935 |
– |
/** |
2936 |
– |
* acceptEitherAsync result completes exceptionally if action does |
2937 |
– |
*/ |
2938 |
– |
public void testAcceptEitherAsync3E() { |
2939 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2940 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2941 |
– |
FailingConsumer r = new FailingConsumer(); |
2942 |
– |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2943 |
– |
f.complete(one); |
2944 |
– |
checkCompletedWithWrappedCFException(g); |
2945 |
– |
} |
2946 |
– |
|
2947 |
– |
/** |
2948 |
– |
* acceptEitherAsync result completes exceptionally if either |
2949 |
– |
* source cancelled |
2950 |
– |
*/ |
2951 |
– |
public void testAcceptEitherAsync4E() { |
2952 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2953 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2954 |
– |
IncAction r = new IncAction(); |
2955 |
– |
CompletableFuture<Void> g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2956 |
– |
assertTrue(f.cancel(true)); |
2957 |
– |
checkCompletedWithWrappedCancellationException(g); |
2958 |
– |
|
2959 |
– |
r = new IncAction(); |
2960 |
– |
f = new CompletableFuture<>(); |
2961 |
– |
f2 = new CompletableFuture<>(); |
2962 |
– |
assertTrue(f2.cancel(true)); |
2963 |
– |
g = f.acceptEitherAsync(f2, r, new ThreadExecutor()); |
2964 |
– |
checkCompletedWithWrappedCancellationException(g); |
2965 |
– |
} |
2966 |
– |
|
2967 |
– |
/** |
2968 |
– |
* runAfterEitherAsync result completes normally after normal |
2969 |
– |
* completion of sources |
2970 |
– |
*/ |
2971 |
– |
public void testRunAfterEitherAsyncE() { |
2972 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2973 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2974 |
– |
Noop r = new Noop(); |
2975 |
– |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
2976 |
– |
f.complete(one); |
2977 |
– |
checkCompletedNormally(g, null); |
2978 |
– |
assertTrue(r.ran); |
2979 |
– |
|
2980 |
– |
r = new Noop(); |
2981 |
– |
f = new CompletableFuture<>(); |
2982 |
– |
f.complete(one); |
2983 |
– |
f2 = new CompletableFuture<>(); |
2984 |
– |
g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
2985 |
– |
checkCompletedNormally(g, null); |
2986 |
– |
assertTrue(r.ran); |
2987 |
– |
} |
2988 |
– |
|
2989 |
– |
/** |
2990 |
– |
* runAfterEitherAsync result completes exceptionally after exceptional |
2991 |
– |
* completion of source |
2992 |
– |
*/ |
2993 |
– |
public void testRunAfterEitherAsync2E() { |
2994 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
2995 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
2996 |
– |
Noop r = new Noop(); |
2997 |
– |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
2998 |
– |
f.completeExceptionally(new CFException()); |
2999 |
– |
checkCompletedWithWrappedCFException(g); |
3000 |
– |
|
3001 |
– |
r = new Noop(); |
3002 |
– |
f = new CompletableFuture<>(); |
3003 |
– |
f2 = new CompletableFuture<>(); |
3004 |
– |
f2.completeExceptionally(new CFException()); |
3005 |
– |
g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
3006 |
– |
f.complete(one); |
3007 |
– |
checkCompletedWithWrappedCFException(g); |
3008 |
– |
} |
3009 |
– |
|
3010 |
– |
/** |
3011 |
– |
* runAfterEitherAsync result completes exceptionally if action does |
3012 |
– |
*/ |
3013 |
– |
public void testRunAfterEitherAsync3E() { |
3014 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3015 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
3016 |
– |
FailingNoop r = new FailingNoop(); |
3017 |
– |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
3018 |
– |
f.complete(one); |
3019 |
– |
checkCompletedWithWrappedCFException(g); |
3020 |
– |
} |
3021 |
– |
|
3022 |
– |
/** |
3023 |
– |
* runAfterEitherAsync result completes exceptionally if either |
3024 |
– |
* source cancelled |
3025 |
– |
*/ |
3026 |
– |
public void testRunAfterEitherAsync4E() { |
3027 |
– |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
3028 |
– |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
3029 |
– |
Noop r = new Noop(); |
3030 |
– |
CompletableFuture<Void> g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
3031 |
– |
assertTrue(f.cancel(true)); |
3032 |
– |
checkCompletedWithWrappedCancellationException(g); |
3033 |
– |
|
3034 |
– |
r = new Noop(); |
3035 |
– |
f = new CompletableFuture<>(); |
3036 |
– |
f2 = new CompletableFuture<>(); |
3037 |
– |
assertTrue(f2.cancel(true)); |
3038 |
– |
g = f.runAfterEitherAsync(f2, r, new ThreadExecutor()); |
3039 |
– |
checkCompletedWithWrappedCancellationException(g); |
3040 |
– |
} |
3041 |
– |
|
3227 |
|
/** |
3228 |
|
* thenComposeAsync result completes normally after normal |
3229 |
|
* completion of source |