mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-11 01:41:47 +01:00
chore: broaden closed channel handling
This commit is contained in:
parent
2065f63f82
commit
187931e50b
@ -13,6 +13,7 @@ import java.io.EOFException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.nio.channels.AsynchronousCloseException;
|
import java.nio.channels.AsynchronousCloseException;
|
||||||
|
import java.nio.channels.ClosedChannelException;
|
||||||
import java.nio.channels.ServerSocketChannel;
|
import java.nio.channels.ServerSocketChannel;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -97,8 +98,8 @@ public final class Server {
|
|||||||
try {
|
try {
|
||||||
// Read & process packets
|
// Read & process packets
|
||||||
connection.read(packetParser);
|
connection.read(packetParser);
|
||||||
} catch (AsynchronousCloseException ignored) {
|
} catch (ClosedChannelException ignored) {
|
||||||
// We closed the socket during read, just exit.
|
break; // We closed the socket during read, just exit.
|
||||||
} catch (EOFException e) {
|
} catch (EOFException e) {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
break;
|
break;
|
||||||
@ -115,8 +116,8 @@ public final class Server {
|
|||||||
while (!stop) {
|
while (!stop) {
|
||||||
try {
|
try {
|
||||||
connection.flushSync();
|
connection.flushSync();
|
||||||
} catch (AsynchronousCloseException ignored) {
|
} catch (ClosedChannelException ignored) {
|
||||||
// We closed the socket during write, just exit.
|
break; // We closed the socket during write, just exit.
|
||||||
} catch (EOFException e) {
|
} catch (EOFException e) {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user