8249217: Unexpected StackOverflowError in "process reaper" thread still happens

Reviewed-by: martin, plevart, dholmes
This commit is contained in:
Roger Riggs 2020-07-24 11:00:50 -04:00
parent e6875c9bac
commit a0149f53f1
2 changed files with 9 additions and 5 deletions

View file

@ -36,6 +36,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.IntStream;
import java.util.stream.Stream;
@ -83,6 +84,9 @@ final class ProcessHandleImpl implements ProcessHandle {
*/
private static final Executor processReaperExecutor =
doPrivileged((PrivilegedAction<Executor>) () -> {
// Initialize ThreadLocalRandom now to avoid using the smaller stack
// of the processReaper threads.
ThreadLocalRandom.current();
ThreadGroup tg = Thread.currentThread().getThreadGroup();
while (tg.getParent() != null) tg = tg.getParent();