Move removal of unix socket file

This commit is contained in:
themode 2022-02-13 16:05:19 +01:00
parent 078d2ef670
commit 49e727d177
2 changed files with 3 additions and 9 deletions

View File

@ -87,13 +87,6 @@ public final class Server {
MinecraftServer.getExceptionManager().handleException(e); MinecraftServer.getExceptionManager().handleException(e);
} }
} }
try {
if (socketAddress instanceof UnixDomainSocketAddress unixDomainSocketAddress) {
Files.deleteIfExists(unixDomainSocketAddress.getPath());
}
} catch (IOException e) {
MinecraftServer.getExceptionManager().handleException(e);
}
}, "Ms-entrypoint").start(); }, "Ms-entrypoint").start();
} }
@ -105,6 +98,9 @@ public final class Server {
this.stop = true; this.stop = true;
try { try {
this.serverSocket.close(); this.serverSocket.close();
if (socketAddress instanceof UnixDomainSocketAddress unixDomainSocketAddress) {
Files.deleteIfExists(unixDomainSocketAddress.getPath());
}
} catch (IOException e) { } catch (IOException e) {
MinecraftServer.getExceptionManager().handleException(e); MinecraftServer.getExceptionManager().handleException(e);
} }

View File

@ -37,8 +37,6 @@ public class ServerAddressTest {
assertDoesNotThrow(server::start); assertDoesNotThrow(server::start);
assertDoesNotThrow(server::stop); assertDoesNotThrow(server::stop);
Thread.sleep(250);
assertFalse(Files.exists(address.getPath()), "The socket file should be deleted"); assertFalse(Files.exists(address.getPath()), "The socket file should be deleted");
} }
} }