diff --git a/common/src/main/java/haveno/common/taskrunner/Task.java b/common/src/main/java/haveno/common/taskrunner/Task.java index 79904de23a..f990f511d8 100644 --- a/common/src/main/java/haveno/common/taskrunner/Task.java +++ b/common/src/main/java/haveno/common/taskrunner/Task.java @@ -74,6 +74,7 @@ public abstract class Task { // t.printStackTrace(pw); // errorMessage = sw.toString(); + if (taskHandler.isCanceled()) return; errorMessage = t.getMessage() + " (task " + getClass().getSimpleName() + ")"; log.error(errorMessage, t); taskHandler.handleErrorMessage(errorMessage); diff --git a/common/src/main/java/haveno/common/taskrunner/TaskRunner.java b/common/src/main/java/haveno/common/taskrunner/TaskRunner.java index 65cbf08e65..e49b4ccd91 100644 --- a/common/src/main/java/haveno/common/taskrunner/TaskRunner.java +++ b/common/src/main/java/haveno/common/taskrunner/TaskRunner.java @@ -80,11 +80,16 @@ public class TaskRunner { isCanceled = true; } + public boolean isCanceled() { + return isCanceled; + } + void handleComplete() { next(); } void handleErrorMessage(String errorMessage) { + if (isCanceled) return; log.error("Task failed: " + currentTask.getSimpleName() + " / errorMessage: " + errorMessage); failed = true; errorMessageHandler.handleErrorMessage(errorMessage); diff --git a/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferProtocol.java b/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferProtocol.java index 0fbd7efef1..32426b80d5 100644 --- a/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferProtocol.java +++ b/core/src/main/java/haveno/core/offer/placeoffer/PlaceOfferProtocol.java @@ -41,6 +41,7 @@ public class PlaceOfferProtocol { private Timer timeoutTimer; private final TransactionResultHandler resultHandler; private final ErrorMessageHandler errorMessageHandler; + private TaskRunner taskRunner; /////////////////////////////////////////////////////////////////////////////////////////// @@ -65,7 +66,7 @@ public class PlaceOfferProtocol { startTimeoutTimer(); - TaskRunner taskRunner = new TaskRunner<>(model, + taskRunner = new TaskRunner<>(model, () -> { // reset timer if response not yet received @@ -145,6 +146,7 @@ public class PlaceOfferProtocol { private void handleError(String errorMessage) { if (timeoutTimer != null) { + taskRunner.cancel(); log.error(errorMessage); stopTimeoutTimer(); model.getOpenOffer().getOffer().setErrorMessage(errorMessage);