ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/CompletableFutureTest.java
(Generate patch)

Comparing jsr166/src/test/tck/CompletableFutureTest.java (file contents):
Revision 1.166 by jsr166, Sun Jul 3 19:38:19 2016 UTC vs.
Revision 1.170 by jsr166, Mon Jul 18 19:30:49 2016 UTC

# Line 4242 | Line 4242 | public class CompletableFutureTest exten
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 >     * Reproduction recipe for:
4247 >     * 8160402: Garbage retention with CompletableFuture.anyOf
4248 >     * cvs update -D '2016-05-01' ./src/main/java/util/concurrent/CompletableFuture.java && ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest -Djsr166.methodFilter=testAnyOfGarbageRetention tck; cvs update -A
4249       */
4249
4250    /** Checks for garbage retention with anyOf. */
4250      public void testAnyOfGarbageRetention() throws Throwable {
4251          for (Integer v : new Integer[] { 1, null })
4252      {
# Line 4261 | Line 4260 | public class CompletableFutureTest exten
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
# Line 4272 | Line 4276 | public class CompletableFutureTest exten
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 +     * 8161600: Garbage retention when source CompletableFutures are never completed
4283 +     *
4284 +     * As of 2016-07, fails with OOME:
4285 +     * ant -Dvmoptions=-Xmx8m -Djsr166.expensiveTests=true -Djsr166.tckTestClass=CompletableFutureTest -Djsr166.methodFilter=testCancelledGarbageRetention tck
4286 +     */
4287 +    public void testCancelledGarbageRetention() throws Throwable {
4288 +        final int n = expensiveTests ? 100_000 : 10;
4289 +        CompletableFuture<Integer> neverCompleted = new CompletableFuture<>();
4290 +        for (int i = 0; i < n; i++)
4291 +            assertTrue(neverCompleted.thenRun(() -> {}).cancel(true));
4292 +    }
4293 +
4294   //     static <U> U join(CompletionStage<U> stage) {
4295   //         CompletableFuture<U> f = new CompletableFuture<>();
4296   //         stage.whenComplete((v, ex) -> {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines