3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-15 03:35:52 +00:00

WalletFiles: Don't save any more if executor is shut down.

This commit is contained in:
Andreas Schildbach 2018-03-30 19:28:02 +02:00
parent e244453073
commit c9a36647a9

View File

@ -113,6 +113,8 @@ public class WalletFiles {
public void saveNow() throws IOException {
// Can be called by any thread. However the wallet is locked whilst saving, so we can have two saves in flight
// but they will serialize (using different temp files).
if (executor.isShutdown())
return;
Date lastBlockSeenTime = wallet.getLastBlockSeenTime();
log.info("Saving wallet; last seen block is height {}, date {}, hash {}", wallet.getLastBlockSeenHeight(),
lastBlockSeenTime != null ? Utils.dateTimeFormat(lastBlockSeenTime) : "unknown",
@ -136,7 +138,7 @@ public class WalletFiles {
/** Queues up a save in the background. Useful for not very important wallet changes. */
public void saveLater() {
if (savePending.getAndSet(true))
if (executor.isShutdown() || savePending.getAndSet(true))
return; // Already pending.
executor.schedule(saver, delay, delayTimeUnit);
}