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

Comparing jsr166/src/test/tck/JSR166TestCase.java (file contents):
Revision 1.145 by jsr166, Fri Sep 25 05:41:29 2015 UTC vs.
Revision 1.146 by jsr166, Fri Sep 25 23:32:15 2015 UTC

# Line 40 | Line 40 | import java.util.concurrent.CyclicBarrie
40   import java.util.concurrent.ExecutionException;
41   import java.util.concurrent.Executors;
42   import java.util.concurrent.ExecutorService;
43 + import java.util.concurrent.ForkJoinPool;
44   import java.util.concurrent.Future;
45   import java.util.concurrent.RecursiveAction;
46   import java.util.concurrent.RecursiveTask;
# Line 521 | Line 522 | public class JSR166TestCase extends Test
522          setDelays();
523      }
524  
525 +    void tearDownFail(String format, Object... args) {
526 +        String msg = toString() + ": " + String.format(format, args);
527 +        System.err.println(msg);
528 +        printAllStackTraces();
529 +        throw new AssertionFailedError(msg);
530 +    }
531 +
532      /**
533       * Extra checks that get done for all test cases.
534       *
# Line 548 | Line 556 | public class JSR166TestCase extends Test
556          }
557  
558          if (Thread.interrupted())
559 <            throw new AssertionFailedError("interrupt status set in main thread");
559 >            tearDownFail("interrupt status set in main thread");
560  
561          checkForkJoinPoolThreadLeaks();
562      }
# Line 557 | Line 565 | public class JSR166TestCase extends Test
565       * Finds missing try { ... } finally { joinPool(e); }
566       */
567      void checkForkJoinPoolThreadLeaks() throws InterruptedException {
568 <        Thread[] survivors = new Thread[5];
568 >        Thread[] survivors = new Thread[7];
569          int count = Thread.enumerate(survivors);
570          for (int i = 0; i < count; i++) {
571              Thread thread = survivors[i];
# Line 565 | Line 573 | public class JSR166TestCase extends Test
573              if (name.startsWith("ForkJoinPool-")) {
574                  // give thread some time to terminate
575                  thread.join(LONG_DELAY_MS);
576 <                if (!thread.isAlive()) continue;
577 <                throw new AssertionFailedError
578 <                    (String.format("Found leaked ForkJoinPool thread test=%s thread=%s%n",
571 <                                   toString(), name));
576 >                if (thread.isAlive())
577 >                    tearDownFail("Found leaked ForkJoinPool thread thread=%s",
578 >                                 thread);
579              }
580          }
581 +
582 +        if (!ForkJoinPool.commonPool()
583 +            .awaitQuiescence(LONG_DELAY_MS, MILLISECONDS))
584 +            tearDownFail("ForkJoin common pool thread stuck");
585      }
586  
587      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines