From 11c8b05f455a3546a5d350bab7824c70d698e457 Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 20 Jan 2024 06:41:24 -0500 Subject: [PATCH] fix ThreadUtils.await() blocking on exception --- .../src/main/java/haveno/common/ThreadUtils.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/haveno/common/ThreadUtils.java b/common/src/main/java/haveno/common/ThreadUtils.java index c2b9aad9..d366b869 100644 --- a/common/src/main/java/haveno/common/ThreadUtils.java +++ b/common/src/main/java/haveno/common/ThreadUtils.java @@ -48,14 +48,25 @@ public class ThreadUtils { } } + /** + * Awaits execution of the given command, but does not throw its exception. + * + * @param command the command to execute + * @param threadId the thread id + */ public static void await(Runnable command, String threadId) { if (isCurrentThread(Thread.currentThread(), threadId)) { command.run(); } else { CountDownLatch latch = new CountDownLatch(1); execute(() -> { - command.run(); - latch.countDown(); + try { + command.run(); + } catch (Exception e) { + throw e; + } finally { + latch.countDown(); + } }, threadId); try { latch.await();