From e1ca35172d891bf5bac9dc9e9bdd0d8afe7b455e Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 20 Dec 2023 08:37:16 -0500 Subject: [PATCH] handle connection disconnect and shut down off UserThread --- .../main/java/haveno/network/p2p/network/Connection.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/p2p/src/main/java/haveno/network/p2p/network/Connection.java b/p2p/src/main/java/haveno/network/p2p/network/Connection.java index b991cae6..4c917037 100644 --- a/p2p/src/main/java/haveno/network/p2p/network/Connection.java +++ b/p2p/src/main/java/haveno/network/p2p/network/Connection.java @@ -32,7 +32,6 @@ import haveno.network.p2p.storage.payload.CapabilityRequiringPayload; import haveno.network.p2p.storage.payload.PersistableNetworkPayload; import haveno.common.Proto; -import haveno.common.UserThread; import haveno.common.app.Capabilities; import haveno.common.app.HasCapabilities; import haveno.common.app.Version; @@ -502,7 +501,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener { handleException(t); } finally { stopped = true; - UserThread.execute(() -> doShutDown(closeConnectionReason, shutDownCompleteHandler)); + EXECUTOR.execute(() -> doShutDown(closeConnectionReason, shutDownCompleteHandler)); } }, "Connection:SendCloseConnectionMessage-" + this.uid).start(); } else { @@ -512,12 +511,12 @@ public class Connection implements HasCapabilities, Runnable, MessageListener { } else { //TODO find out why we get called that log.debug("stopped was already at shutDown call"); - UserThread.execute(() -> doShutDown(closeConnectionReason, shutDownCompleteHandler)); + EXECUTOR.execute(() -> doShutDown(closeConnectionReason, shutDownCompleteHandler)); } } private void doShutDown(CloseConnectionReason closeConnectionReason, @Nullable Runnable shutDownCompleteHandler) { - UserThread.execute(() -> connectionListener.onDisconnect(closeConnectionReason, this)); + EXECUTOR.execute(() -> connectionListener.onDisconnect(closeConnectionReason, this)); try { protoOutputStream.onConnectionShutdown(); socket.close(); @@ -540,7 +539,7 @@ public class Connection implements HasCapabilities, Runnable, MessageListener { log.debug("Connection shutdown complete {}", this); if (shutDownCompleteHandler != null) - UserThread.execute(shutDownCompleteHandler); + EXECUTOR.execute(shutDownCompleteHandler); } }