Skip to content

Commit 51f8346

Browse files
authored
Set executor shutdown delay on existing tasks to false. (#144)
* Set executor shutdown time to 0 to prevent application hanging. * Disable tasks after shutdown.
1 parent 76ef18e commit 51f8346

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,15 @@ public final class CoreSocketFactory {
112112
this.credential = credential;
113113
this.adminApi = adminApi;
114114
this.serverProxyPort = serverProxyPort;
115+
116+
// TODO(kvg): Figure out correct way to determine number of threads
117+
ScheduledThreadPoolExecutor executor =
118+
(ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(2);
119+
executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
120+
115121
this.executor =
116122
MoreExecutors.listeningDecorator(
117-
MoreExecutors.getExitingScheduledExecutorService(
118-
(ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(2)));
123+
MoreExecutors.getExitingScheduledExecutorService(executor));
119124
}
120125

121126
/** Returns the {@link CoreSocketFactory} singleton. */

0 commit comments

Comments
 (0)