Skip to content

Commit 6defeb3

Browse files
authored
fix: use daemon threads internally (#618)
Without using daemon threads, the Connector will prevent a calling process from exiting cleanly. Fixes #617
1 parent 508df91 commit 6defeb3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

alloydb-jdbc-connector/src/main/java/com/google/cloud/alloydb/InternalConnectorRegistry.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ enum InternalConnectorRegistry implements Closeable {
6565
// there should be enough free threads so that there will not be a deadlock. Most users
6666
// configure 3 or fewer instances, requiring 6 threads during refresh. By setting
6767
// this to 8, it's enough threads for most users, plus a safety factor of 2.
68-
this.executor = MoreExecutors.listeningDecorator(Executors.newScheduledThreadPool(8));
68+
this.executor =
69+
MoreExecutors.listeningDecorator(
70+
Executors.newScheduledThreadPool(
71+
8,
72+
r -> {
73+
Thread t = new Thread(r);
74+
t.setDaemon(true);
75+
return t;
76+
}));
6977
this.unnamedConnectors = new ConcurrentHashMap<>();
7078
this.namedConnectors = new ConcurrentHashMap<>();
7179
this.credentialFactoryProvider = new CredentialFactoryProvider();

0 commit comments

Comments
 (0)