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.102 by jsr166, Wed Feb 6 19:55:06 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines