From 56e61e611cb94898e38aaf67b63fe1e79556d12b Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 30 Apr 2023 11:05:06 -0400 Subject: [PATCH] continue shutting down on error flushing data to disk --- .../haveno/common/persistence/PersistenceManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/haveno/common/persistence/PersistenceManager.java b/common/src/main/java/haveno/common/persistence/PersistenceManager.java index bbf249ab81..9804798bbd 100644 --- a/common/src/main/java/haveno/common/persistence/PersistenceManager.java +++ b/common/src/main/java/haveno/common/persistence/PersistenceManager.java @@ -150,12 +150,18 @@ public class PersistenceManager { // (fixes https://github.com/bisq-network/bisq/issues/4844). if (persistenceManager.readCalled.get() && (persistenceManager.source.flushAtShutDown || persistenceManager.persistenceRequested)) { + // We always get our completeHandler called even if exceptions happen. In case a file write fails // we still call our shutdown and count down routine as the completeHandler is triggered in any case. - // We get our result handler called from the write thread so we map back to user thread. - persistenceManager.persistNow(() -> + try { + persistenceManager.persistNow(() -> UserThread.execute(() -> onWriteCompleted(completeHandler, openInstances, persistenceManager, doShutdown))); + } catch (Exception e) { + if (!doShutdown) throw e; // only complete if shutting down + log.warn("Error flushing data to disk on shut down. Calling completeHandler."); + UserThread.execute(() -> onWriteCompleted(completeHandler, openInstances, persistenceManager, doShutdown)); + } } else { onWriteCompleted(completeHandler, openInstances, persistenceManager, doShutdown); }