mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +00:00
fix error changing wallet password from default password
HavenoUtils.executeTasks() throws exception from any tasks
This commit is contained in:
parent
f1b9829b09
commit
350d2d5398
2 changed files with 14 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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<Runnable> tasks, int poolSize) {
|
||||
if (tasks.isEmpty()) return;
|
||||
ExecutorService pool = Executors.newFixedThreadPool(poolSize);
|
||||
for (Runnable task : tasks) pool.submit(task);
|
||||
List<Future<?>> futures = new ArrayList<Future<?>>();
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue