From 350d2d53980648e7ff5a65225965fe35d67cc886 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 19 Jan 2023 19:27:39 -0500 Subject: [PATCH] fix error changing wallet password from default password HavenoUtils.executeTasks() throws exception from any tasks --- .../java/bisq/core/btc/wallet/XmrWalletService.java | 2 ++ core/src/main/java/bisq/core/trade/HavenoUtils.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java b/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java index 32708ad26c..edc52281f4 100644 --- a/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java +++ b/core/src/main/java/bisq/core/btc/wallet/XmrWalletService.java @@ -152,6 +152,8 @@ public class XmrWalletService { @Override public void onPasswordChanged(String oldPassword, String newPassword) { log.info(getClass() + "accountservice.onPasswordChanged()"); + if (oldPassword == null) oldPassword = MONERO_WALLET_RPC_DEFAULT_PASSWORD; + if (newPassword == null) newPassword = MONERO_WALLET_RPC_DEFAULT_PASSWORD; changeWalletPasswords(oldPassword, newPassword); } }); diff --git a/core/src/main/java/bisq/core/trade/HavenoUtils.java b/core/src/main/java/bisq/core/trade/HavenoUtils.java index 70bbc1373e..33817d777a 100644 --- a/core/src/main/java/bisq/core/trade/HavenoUtils.java +++ b/core/src/main/java/bisq/core/trade/HavenoUtils.java @@ -38,10 +38,13 @@ import lombok.extern.slf4j.Slf4j; import java.math.BigDecimal; import java.math.BigInteger; import java.net.URI; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; @@ -350,7 +353,8 @@ public class HavenoUtils { public static void executeTasks(Collection tasks, int poolSize) { if (tasks.isEmpty()) return; ExecutorService pool = Executors.newFixedThreadPool(poolSize); - for (Runnable task : tasks) pool.submit(task); + List> futures = new ArrayList>(); + for (Runnable task : tasks) futures.add(pool.submit(task)); pool.shutdown(); try { if (!pool.awaitTermination(60, TimeUnit.SECONDS)) pool.shutdownNow(); @@ -358,6 +362,13 @@ public class HavenoUtils { pool.shutdownNow(); throw new RuntimeException(e); } + + // throw exception from any tasks + try { + for (Future future : futures) future.get(); + } catch (Exception e) { + throw new RuntimeException(e); + } } public static String toCamelCase(String underscore) {