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.98 by jsr166, Sun Feb 3 06:20:32 2013 UTC vs.
Revision 1.103 by dl, Wed Mar 20 20:29:02 2013 UTC

# Line 286 | Line 286 | public class JSR166TestCase extends Test
286          // Java8+ test classes
287          if (atLeastJava8()) {
288              String[] java8TestClassNames = {
289 +                "LongAdderTest",
290 +                "LongAccumulatorTest",
291 +                "DoubleAdderTest",
292 +                "DoubleAccumulatorTest",
293 +                "CompletableFutureTest",
294 +                "ForkJoinPool8Test",
295                  "StampedLockTest",
296              };
297              addNamedTestClasses(suite, java8TestClassNames);
# Line 383 | Line 389 | public class JSR166TestCase extends Test
389  
390          if (Thread.interrupted())
391              throw new AssertionFailedError("interrupt status set in main thread");
392 +
393 +        checkForkJoinPoolThreadLeaks();
394 +    }
395 +
396 +    /**
397 +     * Find missing try { ... } finally { joinPool(e); }
398 +     */
399 +    void checkForkJoinPoolThreadLeaks() throws InterruptedException {
400 +        Thread[] survivors = new Thread[5];
401 +        int count = Thread.enumerate(survivors);
402 +        for (int i = 0; i < count; i++) {
403 +            Thread thread = survivors[i];
404 +            String name = thread.getName();
405 +            if (name.startsWith("ForkJoinPool-")) {
406 +                // give thread some time to terminate
407 +                thread.join(LONG_DELAY_MS);
408 +                if (!thread.isAlive()) continue;
409 +                thread.stop();
410 +                throw new AssertionFailedError
411 +                    (String.format("Found leaked ForkJoinPool thread test=%s thread=%s%n",
412 +                                   toString(), name));
413 +            }
414 +        }
415      }
416  
417      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines