mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-28 06:27:27 +02:00
Fix NullPointerException, deadlock when stopping the server (#1220)
This commit is contained in:
parent
de5a396c15
commit
0989c220f6
@ -97,7 +97,10 @@ public final class Server {
|
||||
public void stop() {
|
||||
this.stop = true;
|
||||
try {
|
||||
this.serverSocket.close();
|
||||
if(serverSocket != null) {
|
||||
this.serverSocket.close();
|
||||
}
|
||||
|
||||
if (socketAddress instanceof UnixDomainSocketAddress unixDomainSocketAddress) {
|
||||
Files.deleteIfExists(unixDomainSocketAddress.getPath());
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class ServerAddressTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unixAddressTest() throws IOException, InterruptedException {
|
||||
public void unixAddressTest() throws IOException {
|
||||
UnixDomainSocketAddress address = UnixDomainSocketAddress.of("minestom.sock");
|
||||
var server = new Server(new PacketProcessor());
|
||||
server.init(address);
|
||||
@ -39,4 +39,10 @@ public class ServerAddressTest {
|
||||
assertDoesNotThrow(server::stop);
|
||||
assertFalse(Files.exists(address.getPath()), "The socket file should be deleted");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noAddressTest() throws IOException {
|
||||
var server = new Server(new PacketProcessor());
|
||||
assertDoesNotThrow(server::stop);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user