From a4355ce1981b0406ffd1654ba0cc8062847f7a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Pl=C3=A1=C5=A1il?= Date: Thu, 12 Jul 2018 01:10:43 +0800 Subject: [PATCH] Configure NetworkMapUpdater executor so that it doesn't block node shutdown (#3530) --- .../net/corda/node/services/network/NetworkMapUpdater.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/node/src/main/kotlin/net/corda/node/services/network/NetworkMapUpdater.kt b/node/src/main/kotlin/net/corda/node/services/network/NetworkMapUpdater.kt index b30e3472e8..d06abce27a 100644 --- a/node/src/main/kotlin/net/corda/node/services/network/NetworkMapUpdater.kt +++ b/node/src/main/kotlin/net/corda/node/services/network/NetworkMapUpdater.kt @@ -28,6 +28,7 @@ import java.nio.file.StandardCopyOption import java.time.Duration import java.util.* import java.util.concurrent.Executors +import java.util.concurrent.ScheduledThreadPoolExecutor import java.util.concurrent.TimeUnit import kotlin.system.exitProcess @@ -45,7 +46,7 @@ class NetworkMapUpdater(private val networkMapCache: NetworkMapCacheInternal, } private val parametersUpdatesTrack: PublishSubject = PublishSubject.create() - private val executor = Executors.newSingleThreadScheduledExecutor(NamedThreadFactory("Network Map Updater Thread", Executors.defaultThreadFactory())) + private val executor = ScheduledThreadPoolExecutor(1, NamedThreadFactory("Network Map Updater Thread", Executors.defaultThreadFactory())) private var newNetworkParameters: Pair? = null private var fileWatcherSubscription: Subscription? = null @@ -81,6 +82,7 @@ class NetworkMapUpdater(private val networkMapCache: NetworkMapCacheInternal, if (networkMapClient == null) return // Subscribe to remote network map if configured. + executor.executeExistingDelayedTasksAfterShutdownPolicy = false executor.submit(object : Runnable { override fun run() { val nextScheduleDelay = try {