286 |
|
// Java8+ test classes |
287 |
|
if (atLeastJava8()) { |
288 |
|
String[] java8TestClassNames = { |
289 |
+ |
"CompletableFutureTest", |
290 |
+ |
"ForkJoinPool8Test", |
291 |
|
"StampedLockTest", |
292 |
|
}; |
293 |
|
addNamedTestClasses(suite, java8TestClassNames); |
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 |
|
/** |