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.99 by jsr166, Tue Feb 5 03:39:34 2013 UTC vs.
Revision 1.100 by jsr166, Wed Feb 6 16:55:50 2013 UTC

# Line 384 | Line 384 | public class JSR166TestCase extends Test
384  
385          if (Thread.interrupted())
386              throw new AssertionFailedError("interrupt status set in main thread");
387 +
388 +        checkForkJoinPoolThreadLeaks();
389      }
390  
391      /**
392 +     * Find missing try { ... } finally { joinPool(e); }
393 +     */
394 +    void checkForkJoinPoolThreadLeaks() throws InterruptedException {
395 +        Thread[] survivors = new Thread[5];
396 +        int count = Thread.enumerate(survivors);
397 +        for (int i = 0; i < count; i++) {
398 +            Thread thread = survivors[i];
399 +            String name = thread.getName();
400 +            if (name.startsWith("ForkJoinPool-")) {
401 +                // give thread some time to terminate
402 +                thread.join(LONG_DELAY_MS);
403 +                if (!thread.isAlive()) continue;
404 +                thread.stop();
405 +                throw new AssertionFailedError
406 +                    (String.format("Found leaked ForkJoinPool thread test=%s thread=%s%n",
407 +                                   toString(), name));
408 +            }
409 +        }
410 +    }
411 +        
412 +    /**
413       * Just like fail(reason), but additionally recording (using
414       * threadRecordFailure) any AssertionFailedError thrown, so that
415       * the current testcase will fail.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines