Fix socket close

This commit is contained in:
themode 2022-02-13 14:34:30 +01:00
parent 945bf6a914
commit 1fe93ce653
2 changed files with 6 additions and 2 deletions

View File

@ -88,7 +88,6 @@ public final class Server {
}
}
try {
serverSocket.close();
if (socketAddress instanceof UnixDomainSocketAddress unixDomainSocketAddress) {
Files.deleteIfExists(unixDomainSocketAddress.getPath());
}
@ -104,6 +103,11 @@ public final class Server {
public void stop() {
this.stop = true;
try {
this.serverSocket.close();
} catch (IOException e) {
MinecraftServer.getExceptionManager().handleException(e);
}
this.selector.wakeup();
this.workers.forEach(worker -> worker.selector.wakeup());
}

View File

@ -22,7 +22,7 @@ public class ServerProcessTest {
@Test
public void tick() {
var process = MinecraftServer.updateProcess();
process.start(new InetSocketAddress("localhost", 25567));
process.start(new InetSocketAddress("localhost", 25565));
var ticker = process.ticker();
assertDoesNotThrow(() -> ticker.tick(System.currentTimeMillis()));
assertDoesNotThrow(process::stop);