From e956114239a6ce34583cf859c8a8db057b3520b0 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 17 Jan 2024 20:36:24 -0500 Subject: [PATCH] shut down OpenOfferManager thread pool before completing shut down --- .../main/java/haveno/core/offer/OpenOfferManager.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index 9cc4098339..030b06d810 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -324,6 +324,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe // Force broadcaster to send out immediately, otherwise we could have a 2 sec delay until the // bundled messages sent out. broadcaster.flush(); + shutDownThreadPool(); if (completeHandler != null) { // For typical number of offers we are tolerant with delay to give enough time to broadcast. @@ -335,12 +336,18 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe }, THREAD_ID); } else { broadcaster.flush(); + shutDownThreadPool(); if (completeHandler != null) completeHandler.run(); } + } - // shut down pool - ThreadUtils.shutDown(THREAD_ID, SHUTDOWN_TIMEOUT_MS); + private void shutDownThreadPool() { + try { + ThreadUtils.shutDown(THREAD_ID, SHUTDOWN_TIMEOUT_MS); + } catch (Exception e) { + log.error("Error shutting down OpenOfferManager thread pool", e); + } } public void removeAllOpenOffers(@Nullable Runnable completeHandler) {