From d609b537b9ac7b51c6d9133737882bf6ffd1f97a Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sun, 6 Sep 2020 16:34:00 +0200 Subject: [PATCH] handle Socket close exception correctly (this is not failed^^) --- .../bixilon/minosoft/protocol/network/Network.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/bixilon/minosoft/protocol/network/Network.java b/src/main/java/de/bixilon/minosoft/protocol/network/Network.java index 15139150d..4171c6b23 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/network/Network.java +++ b/src/main/java/de/bixilon/minosoft/protocol/network/Network.java @@ -35,6 +35,7 @@ import java.io.OutputStream; import java.lang.reflect.InvocationTargetException; import java.net.InetSocketAddress; import java.net.Socket; +import java.net.SocketException; import java.util.concurrent.LinkedBlockingQueue; public class Network { @@ -238,14 +239,17 @@ public class Network { disconnect(); } catch (IOException e) { // Could not connect - lastException = e; - connection.setConnectionState(ConnectionStates.FAILED); - if (socketSThread != null) { - socketSThread.interrupt(); - } if (Log.getLevel().ordinal() >= LogLevels.DEBUG.ordinal()) { e.printStackTrace(); } + if (socketSThread != null) { + socketSThread.interrupt(); + } + if (e instanceof SocketException && e.getMessage().equals("Socket closed")) { + return; + } + lastException = e; + connection.setConnectionState(ConnectionStates.FAILED); } }); socketRThread.setName(String.format("%d/Socket", connection.getConnectionId()));