102 |
|
assertTrue(f.toString().contains("[Completed exceptionally]")); |
103 |
|
} |
104 |
|
|
105 |
+ |
void checkCompletedWithWrappedCFException(CompletableFuture<?> f, |
106 |
+ |
CFException ex) { |
107 |
+ |
try { |
108 |
+ |
f.get(LONG_DELAY_MS, MILLISECONDS); |
109 |
+ |
shouldThrow(); |
110 |
+ |
} catch (ExecutionException success) { |
111 |
+ |
assertSame(ex, success.getCause()); |
112 |
+ |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
113 |
+ |
try { |
114 |
+ |
f.join(); |
115 |
+ |
shouldThrow(); |
116 |
+ |
} catch (CompletionException success) { |
117 |
+ |
assertSame(ex, success.getCause()); |
118 |
+ |
} |
119 |
+ |
try { |
120 |
+ |
f.getNow(null); |
121 |
+ |
shouldThrow(); |
122 |
+ |
} catch (CompletionException success) { |
123 |
+ |
assertSame(ex, success.getCause()); |
124 |
+ |
} |
125 |
+ |
try { |
126 |
+ |
f.get(); |
127 |
+ |
shouldThrow(); |
128 |
+ |
} catch (ExecutionException success) { |
129 |
+ |
assertSame(ex, success.getCause()); |
130 |
+ |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
131 |
+ |
assertTrue(f.isDone()); |
132 |
+ |
assertFalse(f.isCancelled()); |
133 |
+ |
assertTrue(f.toString().contains("[Completed exceptionally]")); |
134 |
+ |
} |
135 |
+ |
|
136 |
|
void checkCancelled(CompletableFuture<?> f) { |
137 |
|
try { |
138 |
|
f.get(LONG_DELAY_MS, MILLISECONDS); |
290 |
|
assertEquals(g.getNumberOfDependents(), 0); |
291 |
|
} |
292 |
|
|
262 |
– |
|
293 |
|
/** |
294 |
|
* toString indicates current completion state |
295 |
|
*/ |
404 |
|
} |
405 |
|
} |
406 |
|
|
377 |
– |
|
407 |
|
/** |
408 |
|
* exceptionally action completes with function value on source |
409 |
< |
* exception; otherwise with source value |
409 |
> |
* exception; otherwise with source value |
410 |
|
*/ |
411 |
|
public void testExceptionally() { |
412 |
|
CompletableFuture<Integer> f = new CompletableFuture<>(); |
692 |
|
checkCompletedWithWrappedCancellationException(g); |
693 |
|
} |
694 |
|
|
666 |
– |
|
695 |
|
/** |
696 |
|
* thenCombine result completes normally after normal completion |
697 |
|
* of sources |
950 |
|
* runAfterBoth result completes normally after normal |
951 |
|
* completion of sources |
952 |
|
*/ |
953 |
< |
public void testRunAfterBoth() { |
954 |
< |
CompletableFuture<Integer> f, g; |
955 |
< |
CompletableFuture<Void> h; |
956 |
< |
Noop r; |
953 |
> |
public void testRunAfterBoth_normalCompletion1() { |
954 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
955 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
956 |
> |
|
957 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
958 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
959 |
> |
final Noop r = new Noop(); |
960 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
961 |
|
|
962 |
< |
f = new CompletableFuture<>(); |
931 |
< |
g = new CompletableFuture<>(); |
932 |
< |
h = f.runAfterBoth(g, r = new Noop()); |
933 |
< |
f.complete(3); |
962 |
> |
f.complete(v1); |
963 |
|
checkIncomplete(h); |
964 |
< |
g.complete(1); |
964 |
> |
assertFalse(r.ran); |
965 |
> |
g.complete(v2); |
966 |
> |
|
967 |
|
checkCompletedNormally(h, null); |
968 |
|
assertTrue(r.ran); |
969 |
+ |
checkCompletedNormally(f, v1); |
970 |
+ |
checkCompletedNormally(g, v2); |
971 |
+ |
} |
972 |
+ |
} |
973 |
|
|
974 |
< |
f = new CompletableFuture<>(); |
975 |
< |
g = new CompletableFuture<>(); |
976 |
< |
h = f.runAfterBoth(g, r = new Noop()); |
977 |
< |
g.complete(1); |
974 |
> |
public void testRunAfterBoth_normalCompletion2() { |
975 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
976 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
977 |
> |
|
978 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
979 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
980 |
> |
final Noop r = new Noop(); |
981 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
982 |
> |
|
983 |
> |
g.complete(v2); |
984 |
|
checkIncomplete(h); |
985 |
< |
f.complete(3); |
985 |
> |
assertFalse(r.ran); |
986 |
> |
f.complete(v1); |
987 |
> |
|
988 |
|
checkCompletedNormally(h, null); |
989 |
|
assertTrue(r.ran); |
990 |
+ |
checkCompletedNormally(f, v1); |
991 |
+ |
checkCompletedNormally(g, v2); |
992 |
+ |
} |
993 |
+ |
} |
994 |
+ |
|
995 |
+ |
public void testRunAfterBoth_normalCompletion3() { |
996 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
997 |
+ |
for (Integer v2 : new Integer[] { 2, null }) { |
998 |
+ |
|
999 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1000 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1001 |
+ |
final Noop r = new Noop(); |
1002 |
+ |
|
1003 |
+ |
g.complete(v2); |
1004 |
+ |
f.complete(v1); |
1005 |
+ |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1006 |
|
|
948 |
– |
f = new CompletableFuture<>(); |
949 |
– |
g = new CompletableFuture<>(); |
950 |
– |
g.complete(1); |
951 |
– |
f.complete(3); |
952 |
– |
h = f.runAfterBoth(g, r = new Noop()); |
1007 |
|
checkCompletedNormally(h, null); |
1008 |
|
assertTrue(r.ran); |
1009 |
+ |
checkCompletedNormally(f, v1); |
1010 |
+ |
checkCompletedNormally(g, v2); |
1011 |
+ |
} |
1012 |
+ |
} |
1013 |
+ |
|
1014 |
+ |
public void testRunAfterBoth_normalCompletion4() { |
1015 |
+ |
for (Integer v1 : new Integer[] { 1, null }) |
1016 |
+ |
for (Integer v2 : new Integer[] { 2, null }) { |
1017 |
+ |
|
1018 |
+ |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1019 |
+ |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1020 |
+ |
final Noop r = new Noop(); |
1021 |
+ |
|
1022 |
+ |
f.complete(v1); |
1023 |
+ |
g.complete(v2); |
1024 |
+ |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1025 |
+ |
|
1026 |
+ |
checkCompletedNormally(h, null); |
1027 |
+ |
assertTrue(r.ran); |
1028 |
+ |
checkCompletedNormally(f, v1); |
1029 |
+ |
checkCompletedNormally(g, v2); |
1030 |
+ |
} |
1031 |
|
} |
1032 |
|
|
1033 |
|
/** |
1034 |
|
* runAfterBoth result completes exceptionally after exceptional |
1035 |
|
* completion of either source |
1036 |
|
*/ |
1037 |
< |
public void testRunAfterBoth2() { |
1038 |
< |
CompletableFuture<Integer> f, g; |
963 |
< |
CompletableFuture<Void> h; |
964 |
< |
Noop r; |
1037 |
> |
public void testRunAfterBoth_exceptionalCompletion1() { |
1038 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1039 |
|
|
1040 |
< |
f = new CompletableFuture<>(); |
1041 |
< |
g = new CompletableFuture<>(); |
1042 |
< |
h = f.runAfterBoth(g, r = new Noop()); |
1043 |
< |
f.completeExceptionally(new CFException()); |
1040 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1041 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1042 |
> |
final Noop r = new Noop(); |
1043 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1044 |
> |
final CFException ex = new CFException(); |
1045 |
> |
|
1046 |
> |
f.completeExceptionally(ex); |
1047 |
|
checkIncomplete(h); |
1048 |
< |
g.complete(1); |
1049 |
< |
checkCompletedWithWrappedCFException(h); |
1048 |
> |
g.complete(v1); |
1049 |
> |
|
1050 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1051 |
> |
checkCompletedWithWrappedCFException(f, ex); |
1052 |
|
assertFalse(r.ran); |
1053 |
+ |
checkCompletedNormally(g, v1); |
1054 |
+ |
} |
1055 |
+ |
} |
1056 |
|
|
1057 |
< |
f = new CompletableFuture<>(); |
1058 |
< |
g = new CompletableFuture<>(); |
1059 |
< |
h = f.runAfterBoth(g, r = new Noop()); |
1060 |
< |
g.completeExceptionally(new CFException()); |
1057 |
> |
public void testRunAfterBoth_exceptionalCompletion2() { |
1058 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1059 |
> |
|
1060 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1061 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1062 |
> |
final Noop r = new Noop(); |
1063 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1064 |
> |
final CFException ex = new CFException(); |
1065 |
> |
|
1066 |
> |
g.completeExceptionally(ex); |
1067 |
|
checkIncomplete(h); |
1068 |
< |
f.complete(3); |
1069 |
< |
checkCompletedWithWrappedCFException(h); |
1068 |
> |
f.complete(v1); |
1069 |
> |
|
1070 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1071 |
> |
checkCompletedWithWrappedCFException(g, ex); |
1072 |
|
assertFalse(r.ran); |
1073 |
+ |
checkCompletedNormally(f, v1); |
1074 |
+ |
} |
1075 |
+ |
} |
1076 |
|
|
1077 |
< |
f = new CompletableFuture<>(); |
1078 |
< |
g = new CompletableFuture<>(); |
1079 |
< |
g.completeExceptionally(new CFException()); |
1080 |
< |
f.complete(3); |
1081 |
< |
h = f.runAfterBoth(g, r = new Noop()); |
1082 |
< |
checkCompletedWithWrappedCFException(h); |
1077 |
> |
public void testRunAfterBoth_exceptionalCompletion3() { |
1078 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1079 |
> |
|
1080 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1081 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1082 |
> |
final Noop r = new Noop(); |
1083 |
> |
final CFException ex = new CFException(); |
1084 |
> |
|
1085 |
> |
g.completeExceptionally(ex); |
1086 |
> |
f.complete(v1); |
1087 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1088 |
> |
|
1089 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1090 |
> |
checkCompletedWithWrappedCFException(g, ex); |
1091 |
|
assertFalse(r.ran); |
1092 |
+ |
checkCompletedNormally(f, v1); |
1093 |
+ |
} |
1094 |
+ |
} |
1095 |
|
|
1096 |
< |
f = new CompletableFuture<>(); |
1097 |
< |
g = new CompletableFuture<>(); |
1098 |
< |
f.completeExceptionally(new CFException()); |
1099 |
< |
g.complete(1); |
1100 |
< |
h = f.runAfterBoth(g, r = new Noop()); |
1101 |
< |
checkCompletedWithWrappedCFException(h); |
1096 |
> |
public void testRunAfterBoth_exceptionalCompletion4() { |
1097 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1098 |
> |
|
1099 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1100 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1101 |
> |
final Noop r = new Noop(); |
1102 |
> |
final CFException ex = new CFException(); |
1103 |
> |
|
1104 |
> |
f.completeExceptionally(ex); |
1105 |
> |
g.complete(v1); |
1106 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1107 |
> |
|
1108 |
> |
checkCompletedWithWrappedCFException(h, ex); |
1109 |
> |
checkCompletedWithWrappedCFException(f, ex); |
1110 |
|
assertFalse(r.ran); |
1111 |
+ |
checkCompletedNormally(g, v1); |
1112 |
+ |
} |
1113 |
|
} |
1114 |
|
|
1115 |
|
/** |
1116 |
|
* runAfterBoth result completes exceptionally if action does |
1117 |
|
*/ |
1118 |
< |
public void testRunAfterBoth3() { |
1119 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
1120 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
1121 |
< |
FailingNoop r = new FailingNoop(); |
1122 |
< |
CompletableFuture<Void> g = f.runAfterBoth(f2, r); |
1123 |
< |
f.complete(one); |
1124 |
< |
checkIncomplete(g); |
1125 |
< |
f2.complete(two); |
1126 |
< |
checkCompletedWithWrappedCFException(g); |
1118 |
> |
public void testRunAfterBoth_actionFailed1() { |
1119 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1120 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
1121 |
> |
|
1122 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1123 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1124 |
> |
final FailingNoop r = new FailingNoop(); |
1125 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1126 |
> |
|
1127 |
> |
f.complete(v1); |
1128 |
> |
checkIncomplete(h); |
1129 |
> |
g.complete(v2); |
1130 |
> |
|
1131 |
> |
checkCompletedWithWrappedCFException(h); |
1132 |
> |
checkCompletedNormally(f, v1); |
1133 |
> |
checkCompletedNormally(g, v2); |
1134 |
> |
} |
1135 |
> |
} |
1136 |
> |
|
1137 |
> |
public void testRunAfterBoth_actionFailed2() { |
1138 |
> |
for (Integer v1 : new Integer[] { 1, null }) |
1139 |
> |
for (Integer v2 : new Integer[] { 2, null }) { |
1140 |
> |
|
1141 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1142 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1143 |
> |
final FailingNoop r = new FailingNoop(); |
1144 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1145 |
> |
|
1146 |
> |
g.complete(v2); |
1147 |
> |
checkIncomplete(h); |
1148 |
> |
f.complete(v1); |
1149 |
> |
|
1150 |
> |
checkCompletedWithWrappedCFException(h); |
1151 |
> |
checkCompletedNormally(f, v1); |
1152 |
> |
checkCompletedNormally(g, v2); |
1153 |
> |
} |
1154 |
|
} |
1155 |
|
|
1156 |
|
/** |
1157 |
|
* runAfterBoth result completes exceptionally if either source cancelled |
1158 |
|
*/ |
1159 |
< |
public void testRunAfterBoth4() { |
1160 |
< |
CompletableFuture<Integer> f = new CompletableFuture<>(); |
1161 |
< |
CompletableFuture<Integer> f2 = new CompletableFuture<>(); |
1162 |
< |
Noop r = new Noop(); |
1163 |
< |
CompletableFuture<Void> g = f.runAfterBoth(f2, r); |
1164 |
< |
assertTrue(f.cancel(true)); |
1165 |
< |
f2.complete(two); |
1166 |
< |
checkCompletedWithWrappedCancellationException(g); |
1167 |
< |
f = new CompletableFuture<>(); |
1168 |
< |
f2 = new CompletableFuture<>(); |
1169 |
< |
r = new Noop(); |
1170 |
< |
g = f.runAfterBoth(f2, r); |
1171 |
< |
f.complete(one); |
1172 |
< |
assertTrue(f2.cancel(true)); |
1173 |
< |
checkCompletedWithWrappedCancellationException(g); |
1159 |
> |
public void testRunAfterBoth_sourceCancelled1() { |
1160 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1161 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1162 |
> |
|
1163 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1164 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1165 |
> |
final Noop r = new Noop(); |
1166 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1167 |
> |
|
1168 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
1169 |
> |
checkIncomplete(h); |
1170 |
> |
g.complete(v1); |
1171 |
> |
|
1172 |
> |
checkCompletedWithWrappedCancellationException(h); |
1173 |
> |
checkCancelled(f); |
1174 |
> |
assertFalse(r.ran); |
1175 |
> |
checkCompletedNormally(g, v1); |
1176 |
> |
} |
1177 |
> |
} |
1178 |
> |
|
1179 |
> |
public void testRunAfterBoth_sourceCancelled2() { |
1180 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1181 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1182 |
> |
|
1183 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1184 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1185 |
> |
final Noop r = new Noop(); |
1186 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1187 |
> |
|
1188 |
> |
assertTrue(g.cancel(mayInterruptIfRunning)); |
1189 |
> |
checkIncomplete(h); |
1190 |
> |
f.complete(v1); |
1191 |
> |
|
1192 |
> |
checkCompletedWithWrappedCancellationException(h); |
1193 |
> |
checkCancelled(g); |
1194 |
> |
assertFalse(r.ran); |
1195 |
> |
checkCompletedNormally(f, v1); |
1196 |
> |
} |
1197 |
> |
} |
1198 |
> |
|
1199 |
> |
public void testRunAfterBoth_sourceCancelled3() { |
1200 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1201 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1202 |
> |
|
1203 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1204 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1205 |
> |
final Noop r = new Noop(); |
1206 |
> |
|
1207 |
> |
assertTrue(g.cancel(mayInterruptIfRunning)); |
1208 |
> |
f.complete(v1); |
1209 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1210 |
> |
|
1211 |
> |
checkCompletedWithWrappedCancellationException(h); |
1212 |
> |
checkCancelled(g); |
1213 |
> |
assertFalse(r.ran); |
1214 |
> |
checkCompletedNormally(f, v1); |
1215 |
> |
} |
1216 |
> |
} |
1217 |
> |
|
1218 |
> |
public void testRunAfterBoth_sourceCancelled4() { |
1219 |
> |
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) |
1220 |
> |
for (Integer v1 : new Integer[] { 1, null }) { |
1221 |
> |
|
1222 |
> |
final CompletableFuture<Integer> f = new CompletableFuture<>(); |
1223 |
> |
final CompletableFuture<Integer> g = new CompletableFuture<>(); |
1224 |
> |
final Noop r = new Noop(); |
1225 |
> |
|
1226 |
> |
assertTrue(f.cancel(mayInterruptIfRunning)); |
1227 |
> |
g.complete(v1); |
1228 |
> |
final CompletableFuture<Void> h = f.runAfterBoth(g, r); |
1229 |
> |
|
1230 |
> |
checkCompletedWithWrappedCancellationException(h); |
1231 |
> |
checkCancelled(f); |
1232 |
> |
assertFalse(r.ran); |
1233 |
> |
checkCompletedNormally(g, v1); |
1234 |
> |
} |
1235 |
|
} |
1236 |
|
|
1237 |
|
/** |
1373 |
|
checkCompletedWithWrappedCancellationException(g); |
1374 |
|
} |
1375 |
|
|
1174 |
– |
|
1376 |
|
/** |
1377 |
|
* runAfterEither result completes normally after normal completion |
1378 |
|
* of either source |
1521 |
|
checkCompletedWithWrappedCancellationException(g); |
1522 |
|
} |
1523 |
|
|
1323 |
– |
|
1524 |
|
// asyncs |
1525 |
|
|
1526 |
|
/** |
1553 |
|
try { |
1554 |
|
g.join(); |
1555 |
|
shouldThrow(); |
1556 |
< |
} catch (Exception ok) { |
1357 |
< |
} |
1556 |
> |
} catch (CompletionException success) {} |
1557 |
|
checkCompletedWithWrappedCFException(g); |
1558 |
|
} |
1559 |
|
|
2287 |
|
checkCompletedWithWrappedCancellationException(g); |
2288 |
|
} |
2289 |
|
|
2091 |
– |
|
2290 |
|
// async with explicit executors |
2291 |
|
|
2292 |
|
/** |
2319 |
|
try { |
2320 |
|
g.join(); |
2321 |
|
shouldThrow(); |
2322 |
< |
} catch (Exception ok) { |
2125 |
< |
} |
2322 |
> |
} catch (CompletionException success) {} |
2323 |
|
checkCompletedWithWrappedCFException(g); |
2324 |
|
} |
2325 |
|
|
3136 |
|
ThreadExecutor exec = new ThreadExecutor(); |
3137 |
|
|
3138 |
|
Runnable[] throwingActions = { |
3139 |
< |
() -> { CompletableFuture.supplyAsync(null); }, |
3140 |
< |
() -> { CompletableFuture.supplyAsync(null, exec); }, |
3141 |
< |
() -> { CompletableFuture.supplyAsync(supplyOne, null); }, |
3142 |
< |
|
3143 |
< |
() -> { CompletableFuture.runAsync(null); }, |
3144 |
< |
() -> { CompletableFuture.runAsync(null, exec); }, |
3145 |
< |
() -> { CompletableFuture.runAsync(() -> {}, null); }, |
3146 |
< |
|
3147 |
< |
() -> { f.completeExceptionally(null); }, |
3148 |
< |
|
3149 |
< |
() -> { f.thenApply(null); }, |
3150 |
< |
() -> { f.thenApplyAsync(null); }, |
3151 |
< |
() -> { f.thenApplyAsync((x) -> x, null); }, |
3152 |
< |
() -> { f.thenApplyAsync(null, exec); }, |
3153 |
< |
|
3154 |
< |
() -> { f.thenAccept(null); }, |
3155 |
< |
() -> { f.thenAcceptAsync(null); }, |
3156 |
< |
() -> { f.thenAcceptAsync((x) -> { ; }, null); }, |
3157 |
< |
() -> { f.thenAcceptAsync(null, exec); }, |
3158 |
< |
|
3159 |
< |
() -> { f.thenRun(null); }, |
3160 |
< |
() -> { f.thenRunAsync(null); }, |
3161 |
< |
() -> { f.thenRunAsync(() -> { ; }, null); }, |
3162 |
< |
() -> { f.thenRunAsync(null, exec); }, |
3163 |
< |
|
3164 |
< |
() -> { f.thenCombine(g, null); }, |
3165 |
< |
() -> { f.thenCombineAsync(g, null); }, |
3166 |
< |
() -> { f.thenCombineAsync(g, null, exec); }, |
3167 |
< |
() -> { f.thenCombine(nullFuture, (x, y) -> x); }, |
3168 |
< |
() -> { f.thenCombineAsync(nullFuture, (x, y) -> x); }, |
3169 |
< |
() -> { f.thenCombineAsync(nullFuture, (x, y) -> x, exec); }, |
3170 |
< |
() -> { f.thenCombineAsync(g, (x, y) -> x, null); }, |
3171 |
< |
|
3172 |
< |
() -> { f.thenAcceptBoth(g, null); }, |
3173 |
< |
() -> { f.thenAcceptBothAsync(g, null); }, |
3174 |
< |
() -> { f.thenAcceptBothAsync(g, null, exec); }, |
3175 |
< |
() -> { f.thenAcceptBoth(nullFuture, (x, y) -> {}); }, |
3176 |
< |
() -> { f.thenAcceptBothAsync(nullFuture, (x, y) -> {}); }, |
3177 |
< |
() -> { f.thenAcceptBothAsync(nullFuture, (x, y) -> {}, exec); }, |
3178 |
< |
() -> { f.thenAcceptBothAsync(g, (x, y) -> {}, null); }, |
3179 |
< |
|
3180 |
< |
() -> { f.runAfterBoth(g, null); }, |
3181 |
< |
() -> { f.runAfterBothAsync(g, null); }, |
3182 |
< |
() -> { f.runAfterBothAsync(g, null, exec); }, |
3183 |
< |
() -> { f.runAfterBoth(nullFuture, () -> {}); }, |
3184 |
< |
() -> { f.runAfterBothAsync(nullFuture, () -> {}); }, |
3185 |
< |
() -> { f.runAfterBothAsync(nullFuture, () -> {}, exec); }, |
3186 |
< |
() -> { f.runAfterBothAsync(g, () -> {}, null); }, |
3187 |
< |
|
3188 |
< |
() -> { f.applyToEither(g, null); }, |
3189 |
< |
() -> { f.applyToEitherAsync(g, null); }, |
3190 |
< |
() -> { f.applyToEitherAsync(g, null, exec); }, |
3191 |
< |
() -> { f.applyToEither(nullFuture, (x) -> x); }, |
3192 |
< |
() -> { f.applyToEitherAsync(nullFuture, (x) -> x); }, |
3193 |
< |
() -> { f.applyToEitherAsync(nullFuture, (x) -> x, exec); }, |
3194 |
< |
() -> { f.applyToEitherAsync(g, (x) -> x, null); }, |
3195 |
< |
|
3196 |
< |
() -> { f.acceptEither(g, null); }, |
3197 |
< |
() -> { f.acceptEitherAsync(g, null); }, |
3198 |
< |
() -> { f.acceptEitherAsync(g, null, exec); }, |
3199 |
< |
() -> { f.acceptEither(nullFuture, (x) -> {}); }, |
3200 |
< |
() -> { f.acceptEitherAsync(nullFuture, (x) -> {}); }, |
3201 |
< |
() -> { f.acceptEitherAsync(nullFuture, (x) -> {}, exec); }, |
3202 |
< |
() -> { f.acceptEitherAsync(g, (x) -> {}, null); }, |
3203 |
< |
|
3204 |
< |
() -> { f.runAfterEither(g, null); }, |
3205 |
< |
() -> { f.runAfterEitherAsync(g, null); }, |
3206 |
< |
() -> { f.runAfterEitherAsync(g, null, exec); }, |
3207 |
< |
() -> { f.runAfterEither(nullFuture, () -> {}); }, |
3208 |
< |
() -> { f.runAfterEitherAsync(nullFuture, () -> {}); }, |
3209 |
< |
() -> { f.runAfterEitherAsync(nullFuture, () -> {}, exec); }, |
3210 |
< |
() -> { f.runAfterEitherAsync(g, () -> {}, null); }, |
3211 |
< |
|
3212 |
< |
() -> { f.thenCompose(null); }, |
3213 |
< |
() -> { f.thenComposeAsync(null); }, |
3214 |
< |
() -> { f.thenComposeAsync(new CompletableFutureInc(), null); }, |
3215 |
< |
() -> { f.thenComposeAsync(null, exec); }, |
3216 |
< |
|
3217 |
< |
() -> { f.exceptionally(null); }, |
3218 |
< |
|
3219 |
< |
() -> { f.handle(null); }, |
3220 |
< |
|
3221 |
< |
() -> { CompletableFuture.allOf((CompletableFuture<?>)null); }, |
3222 |
< |
() -> { CompletableFuture.allOf((CompletableFuture<?>[])null); }, |
3223 |
< |
() -> { CompletableFuture.allOf(f, null); }, |
3224 |
< |
() -> { CompletableFuture.allOf(null, f); }, |
3225 |
< |
|
3226 |
< |
() -> { CompletableFuture.anyOf((CompletableFuture<?>)null); }, |
3227 |
< |
() -> { CompletableFuture.anyOf((CompletableFuture<?>[])null); }, |
3228 |
< |
() -> { CompletableFuture.anyOf(f, null); }, |
3229 |
< |
() -> { CompletableFuture.anyOf(null, f); }, |
3139 |
> |
() -> CompletableFuture.supplyAsync(null), |
3140 |
> |
() -> CompletableFuture.supplyAsync(null, exec), |
3141 |
> |
() -> CompletableFuture.supplyAsync(supplyOne, null), |
3142 |
> |
|
3143 |
> |
() -> CompletableFuture.runAsync(null), |
3144 |
> |
() -> CompletableFuture.runAsync(null, exec), |
3145 |
> |
() -> CompletableFuture.runAsync(() -> {}, null), |
3146 |
> |
|
3147 |
> |
() -> f.completeExceptionally(null), |
3148 |
> |
|
3149 |
> |
() -> f.thenApply(null), |
3150 |
> |
() -> f.thenApplyAsync(null), |
3151 |
> |
() -> f.thenApplyAsync((x) -> x, null), |
3152 |
> |
() -> f.thenApplyAsync(null, exec), |
3153 |
> |
|
3154 |
> |
() -> f.thenAccept(null), |
3155 |
> |
() -> f.thenAcceptAsync(null), |
3156 |
> |
() -> f.thenAcceptAsync((x) -> {} , null), |
3157 |
> |
() -> f.thenAcceptAsync(null, exec), |
3158 |
> |
|
3159 |
> |
() -> f.thenRun(null), |
3160 |
> |
() -> f.thenRunAsync(null), |
3161 |
> |
() -> f.thenRunAsync(() -> {} , null), |
3162 |
> |
() -> f.thenRunAsync(null, exec), |
3163 |
> |
|
3164 |
> |
() -> f.thenCombine(g, null), |
3165 |
> |
() -> f.thenCombineAsync(g, null), |
3166 |
> |
() -> f.thenCombineAsync(g, null, exec), |
3167 |
> |
() -> f.thenCombine(nullFuture, (x, y) -> x), |
3168 |
> |
() -> f.thenCombineAsync(nullFuture, (x, y) -> x), |
3169 |
> |
() -> f.thenCombineAsync(nullFuture, (x, y) -> x, exec), |
3170 |
> |
() -> f.thenCombineAsync(g, (x, y) -> x, null), |
3171 |
> |
|
3172 |
> |
() -> f.thenAcceptBoth(g, null), |
3173 |
> |
() -> f.thenAcceptBothAsync(g, null), |
3174 |
> |
() -> f.thenAcceptBothAsync(g, null, exec), |
3175 |
> |
() -> f.thenAcceptBoth(nullFuture, (x, y) -> {}), |
3176 |
> |
() -> f.thenAcceptBothAsync(nullFuture, (x, y) -> {}), |
3177 |
> |
() -> f.thenAcceptBothAsync(nullFuture, (x, y) -> {}, exec), |
3178 |
> |
() -> f.thenAcceptBothAsync(g, (x, y) -> {}, null), |
3179 |
> |
|
3180 |
> |
() -> f.runAfterBoth(g, null), |
3181 |
> |
() -> f.runAfterBothAsync(g, null), |
3182 |
> |
() -> f.runAfterBothAsync(g, null, exec), |
3183 |
> |
() -> f.runAfterBoth(nullFuture, () -> {}), |
3184 |
> |
() -> f.runAfterBothAsync(nullFuture, () -> {}), |
3185 |
> |
() -> f.runAfterBothAsync(nullFuture, () -> {}, exec), |
3186 |
> |
() -> f.runAfterBothAsync(g, () -> {}, null), |
3187 |
> |
|
3188 |
> |
() -> f.applyToEither(g, null), |
3189 |
> |
() -> f.applyToEitherAsync(g, null), |
3190 |
> |
() -> f.applyToEitherAsync(g, null, exec), |
3191 |
> |
() -> f.applyToEither(nullFuture, (x) -> x), |
3192 |
> |
() -> f.applyToEitherAsync(nullFuture, (x) -> x), |
3193 |
> |
() -> f.applyToEitherAsync(nullFuture, (x) -> x, exec), |
3194 |
> |
() -> f.applyToEitherAsync(g, (x) -> x, null), |
3195 |
> |
|
3196 |
> |
() -> f.acceptEither(g, null), |
3197 |
> |
() -> f.acceptEitherAsync(g, null), |
3198 |
> |
() -> f.acceptEitherAsync(g, null, exec), |
3199 |
> |
() -> f.acceptEither(nullFuture, (x) -> {}), |
3200 |
> |
() -> f.acceptEitherAsync(nullFuture, (x) -> {}), |
3201 |
> |
() -> f.acceptEitherAsync(nullFuture, (x) -> {}, exec), |
3202 |
> |
() -> f.acceptEitherAsync(g, (x) -> {}, null), |
3203 |
> |
|
3204 |
> |
() -> f.runAfterEither(g, null), |
3205 |
> |
() -> f.runAfterEitherAsync(g, null), |
3206 |
> |
() -> f.runAfterEitherAsync(g, null, exec), |
3207 |
> |
() -> f.runAfterEither(nullFuture, () -> {}), |
3208 |
> |
() -> f.runAfterEitherAsync(nullFuture, () -> {}), |
3209 |
> |
() -> f.runAfterEitherAsync(nullFuture, () -> {}, exec), |
3210 |
> |
() -> f.runAfterEitherAsync(g, () -> {}, null), |
3211 |
> |
|
3212 |
> |
() -> f.thenCompose(null), |
3213 |
> |
() -> f.thenComposeAsync(null), |
3214 |
> |
() -> f.thenComposeAsync(new CompletableFutureInc(), null), |
3215 |
> |
() -> f.thenComposeAsync(null, exec), |
3216 |
> |
|
3217 |
> |
() -> f.exceptionally(null), |
3218 |
> |
|
3219 |
> |
() -> f.handle(null), |
3220 |
> |
|
3221 |
> |
() -> CompletableFuture.allOf((CompletableFuture<?>)null), |
3222 |
> |
() -> CompletableFuture.allOf((CompletableFuture<?>[])null), |
3223 |
> |
() -> CompletableFuture.allOf(f, null), |
3224 |
> |
() -> CompletableFuture.allOf(null, f), |
3225 |
> |
|
3226 |
> |
() -> CompletableFuture.anyOf((CompletableFuture<?>)null), |
3227 |
> |
() -> CompletableFuture.anyOf((CompletableFuture<?>[])null), |
3228 |
> |
() -> CompletableFuture.anyOf(f, null), |
3229 |
> |
() -> CompletableFuture.anyOf(null, f), |
3230 |
> |
|
3231 |
> |
() -> f.obtrudeException(null), |
3232 |
|
}; |
3233 |
|
|
3234 |
|
assertThrows(NullPointerException.class, throwingActions); |
3380 |
|
checkCompletedWithWrappedCFException(g); |
3381 |
|
} |
3382 |
|
|
3184 |
– |
|
3383 |
|
/** |
3384 |
< |
* handleAsync action action completes normally with function |
3385 |
< |
* value on either normal or exceptional completion of source |
3384 |
> |
* handleAsync action completes normally with function value on |
3385 |
> |
* either normal or exceptional completion of source |
3386 |
|
*/ |
3387 |
|
public void testHandleAsync() { |
3388 |
|
CompletableFuture<Integer> f, g; |