mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-25 07:19:30 -05:00
ignore failure after task runner canceled
This commit is contained in:
parent
58cead6035
commit
76859f822e
@ -74,6 +74,7 @@ public abstract class Task<T extends Model> {
|
|||||||
// t.printStackTrace(pw);
|
// t.printStackTrace(pw);
|
||||||
// errorMessage = sw.toString();
|
// errorMessage = sw.toString();
|
||||||
|
|
||||||
|
if (taskHandler.isCanceled()) return;
|
||||||
errorMessage = t.getMessage() + " (task " + getClass().getSimpleName() + ")";
|
errorMessage = t.getMessage() + " (task " + getClass().getSimpleName() + ")";
|
||||||
log.error(errorMessage, t);
|
log.error(errorMessage, t);
|
||||||
taskHandler.handleErrorMessage(errorMessage);
|
taskHandler.handleErrorMessage(errorMessage);
|
||||||
|
@ -80,11 +80,16 @@ public class TaskRunner<T extends Model> {
|
|||||||
isCanceled = true;
|
isCanceled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCanceled() {
|
||||||
|
return isCanceled;
|
||||||
|
}
|
||||||
|
|
||||||
void handleComplete() {
|
void handleComplete() {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleErrorMessage(String errorMessage) {
|
void handleErrorMessage(String errorMessage) {
|
||||||
|
if (isCanceled) return;
|
||||||
log.error("Task failed: " + currentTask.getSimpleName() + " / errorMessage: " + errorMessage);
|
log.error("Task failed: " + currentTask.getSimpleName() + " / errorMessage: " + errorMessage);
|
||||||
failed = true;
|
failed = true;
|
||||||
errorMessageHandler.handleErrorMessage(errorMessage);
|
errorMessageHandler.handleErrorMessage(errorMessage);
|
||||||
|
@ -41,6 +41,7 @@ public class PlaceOfferProtocol {
|
|||||||
private Timer timeoutTimer;
|
private Timer timeoutTimer;
|
||||||
private final TransactionResultHandler resultHandler;
|
private final TransactionResultHandler resultHandler;
|
||||||
private final ErrorMessageHandler errorMessageHandler;
|
private final ErrorMessageHandler errorMessageHandler;
|
||||||
|
private TaskRunner<PlaceOfferModel> taskRunner;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -65,7 +66,7 @@ public class PlaceOfferProtocol {
|
|||||||
|
|
||||||
startTimeoutTimer();
|
startTimeoutTimer();
|
||||||
|
|
||||||
TaskRunner<PlaceOfferModel> taskRunner = new TaskRunner<>(model,
|
taskRunner = new TaskRunner<>(model,
|
||||||
() -> {
|
() -> {
|
||||||
|
|
||||||
// reset timer if response not yet received
|
// reset timer if response not yet received
|
||||||
@ -145,6 +146,7 @@ public class PlaceOfferProtocol {
|
|||||||
|
|
||||||
private void handleError(String errorMessage) {
|
private void handleError(String errorMessage) {
|
||||||
if (timeoutTimer != null) {
|
if (timeoutTimer != null) {
|
||||||
|
taskRunner.cancel();
|
||||||
log.error(errorMessage);
|
log.error(errorMessage);
|
||||||
stopTimeoutTimer();
|
stopTimeoutTimer();
|
||||||
model.getOpenOffer().getOffer().setErrorMessage(errorMessage);
|
model.getOpenOffer().getOffer().setErrorMessage(errorMessage);
|
||||||
|
Loading…
Reference in New Issue
Block a user