From b95bc5511bce1352ae1827676cd4ff628f056793 Mon Sep 17 00:00:00 2001 From: Diana Krepinska Vilkolakova Date: Tue, 19 Oct 2021 12:05:50 +0200 Subject: [PATCH] [ELY-2195] Use daemon threads in default ScheduledExecutorService --- .../org/wildfly/security/auth/server/SecurityDomain.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/auth/server/base/src/main/java/org/wildfly/security/auth/server/SecurityDomain.java b/auth/server/base/src/main/java/org/wildfly/security/auth/server/SecurityDomain.java index 93ba7e8d45f..5464b7989e6 100644 --- a/auth/server/base/src/main/java/org/wildfly/security/auth/server/SecurityDomain.java +++ b/auth/server/base/src/main/java/org/wildfly/security/auth/server/SecurityDomain.java @@ -33,6 +33,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.function.Consumer; @@ -1242,7 +1243,12 @@ private void assertNotBuilt() { private static class ScheduledExecutorServiceProvider { - private static final ScheduledThreadPoolExecutor INSTANCE = new ScheduledThreadPoolExecutor(1); + private static final ScheduledThreadPoolExecutor INSTANCE = new ScheduledThreadPoolExecutor(1, runnable -> { + // use daemon thread + Thread thread = Executors.defaultThreadFactory().newThread(runnable); + thread.setDaemon(true); + return thread; + }); static { INSTANCE.setRemoveOnCancelPolicy(true);