diff --git a/common/src/main/java/bisq/common/util/Utilities.java b/common/src/main/java/bisq/common/util/Utilities.java index d4f0def0964..7acf8b6dfcd 100644 --- a/common/src/main/java/bisq/common/util/Utilities.java +++ b/common/src/main/java/bisq/common/util/Utilities.java @@ -178,16 +178,9 @@ private static ThreadPoolExecutor getThreadPoolExecutor(String name, return executor; } - // TODO: Can some/all of the uses of this be replaced by guava MoreExecutors.shutdownAndAwaitTermination(..)? public static void shutdownAndAwaitTermination(ExecutorService executor, long timeout, TimeUnit unit) { - executor.shutdown(); - try { - if (!executor.awaitTermination(timeout, unit)) { - executor.shutdownNow(); - } - } catch (InterruptedException e) { - executor.shutdownNow(); - } + //noinspection UnstableApiUsage + MoreExecutors.shutdownAndAwaitTermination(executor, timeout, unit); } public static FutureCallback failureCallback(Consumer errorHandler) { diff --git a/core/src/main/java/bisq/core/dao/node/full/rpc/BitcoindDaemon.java b/core/src/main/java/bisq/core/dao/node/full/rpc/BitcoindDaemon.java index b632eff4a4a..8da2d8b8954 100644 --- a/core/src/main/java/bisq/core/dao/node/full/rpc/BitcoindDaemon.java +++ b/core/src/main/java/bisq/core/dao/node/full/rpc/BitcoindDaemon.java @@ -110,8 +110,8 @@ public void shutdown() { } catch (IOException e) { log.error("Error closing block notification server socket", e); } finally { - Utilities.shutdownAndAwaitTermination(executor, 1, TimeUnit.SECONDS); - Utilities.shutdownAndAwaitTermination(workerPool, 5, TimeUnit.SECONDS); + Utilities.shutdownAndAwaitTermination(executor, 2, TimeUnit.SECONDS); + Utilities.shutdownAndAwaitTermination(workerPool, 10, TimeUnit.SECONDS); } } diff --git a/core/src/main/java/bisq/core/provider/price/PriceRequest.java b/core/src/main/java/bisq/core/provider/price/PriceRequest.java index da3af881f7c..fa1a4279a66 100644 --- a/core/src/main/java/bisq/core/provider/price/PriceRequest.java +++ b/core/src/main/java/bisq/core/provider/price/PriceRequest.java @@ -78,6 +78,6 @@ public void shutDown() { if (provider != null) { provider.shutDown(); } - Utilities.shutdownAndAwaitTermination(executorService, 1, TimeUnit.SECONDS); + Utilities.shutdownAndAwaitTermination(executorService, 2, TimeUnit.SECONDS); } } diff --git a/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java b/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java index c775d11bd7e..27b7bdae749 100644 --- a/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java +++ b/seednode/src/main/java/bisq/seednode/reporting/SeedNodeReportingService.java @@ -263,7 +263,7 @@ public void shutDown() { dataReportTimer.stop(); } - Utilities.shutdownAndAwaitTermination(executor, 2, TimeUnit.SECONDS); + Utilities.shutdownAndAwaitTermination(executor, 4, TimeUnit.SECONDS); } private void sendHeartBeat() {