handle Socket close exception correctly (this is not failed^^)

This commit is contained in:
Bixilon 2020-09-06 16:34:00 +02:00
parent 744189c745
commit d609b537b9
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -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()));