mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Check if setException returns false and if so, cancel future.
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
5e29bfe4c2
commit
5efd13a678
@ -56,7 +56,10 @@ public class FeeRequest {
|
||||
}
|
||||
|
||||
public void onFailure(@NotNull Throwable throwable) {
|
||||
resultFuture.setException(throwable);
|
||||
if (!resultFuture.setException(throwable)) {
|
||||
// In case the setException returns false we need to cancel the future.
|
||||
resultFuture.cancel(true);
|
||||
}
|
||||
}
|
||||
}, MoreExecutors.directExecutor());
|
||||
|
||||
|
@ -69,7 +69,10 @@ public class MempoolRequest {
|
||||
}
|
||||
|
||||
public void onFailure(@NotNull Throwable throwable) {
|
||||
mempoolServiceCallback.setException(throwable);
|
||||
if (!mempoolServiceCallback.setException(throwable)) {
|
||||
// In case the setException returns false we need to cancel the future.
|
||||
mempoolServiceCallback.cancel(true);
|
||||
}
|
||||
}
|
||||
}, MoreExecutors.directExecutor());
|
||||
}
|
||||
|
@ -65,7 +65,10 @@ public class PriceRequest {
|
||||
|
||||
public void onFailure(@NotNull Throwable throwable) {
|
||||
if (!shutDownRequested) {
|
||||
resultFuture.setException(new PriceRequestException(throwable, baseUrl));
|
||||
if (!resultFuture.setException(new PriceRequestException(throwable, baseUrl))) {
|
||||
// In case the setException returns false we need to cancel the future.
|
||||
resultFuture.cancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, MoreExecutors.directExecutor());
|
||||
|
@ -240,7 +240,12 @@ public abstract class NetworkNode implements MessageListener {
|
||||
|
||||
public void onFailure(@NotNull Throwable throwable) {
|
||||
log.debug("onFailure at sendMessage: peersNodeAddress={}\n\tmessage={}\n\tthrowable={}", peersNodeAddress, networkEnvelope.getClass().getSimpleName(), throwable.toString());
|
||||
UserThread.execute(() -> resultFuture.setException(throwable));
|
||||
UserThread.execute(() -> {
|
||||
if (!resultFuture.setException(throwable)) {
|
||||
// In case the setException returns false we need to cancel the future.
|
||||
resultFuture.cancel(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, MoreExecutors.directExecutor());
|
||||
|
||||
@ -311,13 +316,23 @@ public abstract class NetworkNode implements MessageListener {
|
||||
}
|
||||
|
||||
public void onFailure(@NotNull Throwable throwable) {
|
||||
UserThread.execute(() -> resultFuture.setException(throwable));
|
||||
UserThread.execute(() -> {
|
||||
if (!resultFuture.setException(throwable)) {
|
||||
// In case the setException returns false we need to cancel the future.
|
||||
resultFuture.cancel(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, MoreExecutors.directExecutor());
|
||||
|
||||
} catch (RejectedExecutionException exception) {
|
||||
log.error("RejectedExecutionException at sendMessage: ", exception);
|
||||
resultFuture.setException(exception);
|
||||
UserThread.execute(() -> {
|
||||
if (!resultFuture.setException(exception)) {
|
||||
// In case the setException returns false we need to cancel the future.
|
||||
resultFuture.cancel(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
return resultFuture;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user