3967 |
|
List<CompletionStage<Integer>> stages = new ArrayList<>(); |
3968 |
|
stages.add(new CompletableFuture<Integer>().minimalCompletionStage()); |
3969 |
|
stages.add(CompletableFuture.completedStage(1)); |
3970 |
+ |
stages.add(CompletableFuture.failedStage(new CFException())); |
3971 |
|
|
3972 |
|
List<Method> bugs = new ArrayList<>(); |
3973 |
|
for (Method method : allMethods) { |
4242 |
|
} |
4243 |
|
} |
4244 |
|
|
4245 |
< |
/* |
4246 |
< |
* Tests below currently fail in stress mode due to memory retention. |
4247 |
< |
* ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest tck |
4245 |
> |
/** |
4246 |
> |
* Checks for garbage retention with anyOf. |
4247 |
> |
* Following used to fail with OOME: |
4248 |
> |
* ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest -Djsr166.methodFilter=testAnyOfGarbageRetention tck |
4249 |
|
*/ |
4248 |
– |
|
4249 |
– |
/** Checks for garbage retention with anyOf. */ |
4250 |
|
public void testAnyOfGarbageRetention() throws Throwable { |
4251 |
|
for (Integer v : new Integer[] { 1, null }) |
4252 |
|
{ |
4260 |
|
checkCompletedNormally(CompletableFuture.anyOf(fs), v); |
4261 |
|
}} |
4262 |
|
|
4263 |
< |
/** Checks for garbage retention with allOf. */ |
4263 |
> |
/** |
4264 |
> |
* Checks for garbage retention with allOf. |
4265 |
> |
* |
4266 |
> |
* As of 2016-07, fails with OOME: |
4267 |
> |
* ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest -Djsr166.methodFilter=testCancelledAllOfGarbageRetention tck |
4268 |
> |
*/ |
4269 |
|
public void testCancelledAllOfGarbageRetention() throws Throwable { |
4270 |
|
final int n = expensiveTests ? 100_000 : 10; |
4271 |
|
CompletableFuture<Integer>[] fs |
4276 |
|
assertTrue(CompletableFuture.allOf(fs).cancel(false)); |
4277 |
|
} |
4278 |
|
|
4279 |
+ |
/** |
4280 |
+ |
* Checks for garbage retention when a dependent future is |
4281 |
+ |
* cancelled and garbage-collected. |
4282 |
+ |
* |
4283 |
+ |
* As of 2016-07, fails with OOME: |
4284 |
+ |
* ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest -Djsr166.methodFilter=testCancelledGarbageRetention tck |
4285 |
+ |
*/ |
4286 |
+ |
public void testCancelledGarbageRetention() throws Throwable { |
4287 |
+ |
final int n = expensiveTests ? 100_000 : 10; |
4288 |
+ |
CompletableFuture<Integer> neverCompleted = new CompletableFuture<>(); |
4289 |
+ |
for (int i = 0; i < n; i++) |
4290 |
+ |
assertTrue(neverCompleted.thenRun(() -> {}).cancel(true)); |
4291 |
+ |
} |
4292 |
+ |
|
4293 |
|
// static <U> U join(CompletionStage<U> stage) { |
4294 |
|
// CompletableFuture<U> f = new CompletableFuture<>(); |
4295 |
|
// stage.whenComplete((v, ex) -> { |