Skip to content

Commit c82d4ca

Browse files
authored
fix: use daemon threads internally (#2118)
* chore(csql): use daemon threads internally
1 parent fd362f1 commit c82d4ca

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

core/src/main/java/com/google/cloud/sql/core/InternalConnectorRegistry.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.util.Properties;
3535
import java.util.concurrent.ConcurrentHashMap;
3636
import java.util.concurrent.Executors;
37-
import java.util.concurrent.ScheduledThreadPoolExecutor;
3837
import org.slf4j.Logger;
3938
import org.slf4j.LoggerFactory;
4039

@@ -147,12 +146,14 @@ static ListeningScheduledExecutorService getDefaultExecutor() {
147146
// configure 3 or fewer instances, requiring 6 threads during refresh. By setting
148147
// this to 8, it's enough threads for most users, plus a safety factor of 2.
149148

150-
ScheduledThreadPoolExecutor executor =
151-
(ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(8);
152-
153-
executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
154149
return MoreExecutors.listeningDecorator(
155-
MoreExecutors.getExitingScheduledExecutorService(executor));
150+
Executors.newScheduledThreadPool(
151+
8,
152+
r -> {
153+
Thread t = new Thread(r);
154+
t.setDaemon(true);
155+
return t;
156+
}));
156157
}
157158

158159
/**

0 commit comments

Comments
 (0)