diff --git a/ice-adapter/src/main/java/com/faforever/iceadapter/gpgnet/GPGNetServer.java b/ice-adapter/src/main/java/com/faforever/iceadapter/gpgnet/GPGNetServer.java index e46a04f..1a0d955 100644 --- a/ice-adapter/src/main/java/com/faforever/iceadapter/gpgnet/GPGNetServer.java +++ b/ice-adapter/src/main/java/com/faforever/iceadapter/gpgnet/GPGNetServer.java @@ -241,7 +241,11 @@ private void onGpgnetConnectionLost() { private void acceptThread() { while (!Thread.currentThread().isInterrupted()) { log.info("Listening for incoming connections from game"); - try (Socket socket = serverSocket.accept()) { + try { + // The socket declaration must not be moved into a try-with-resources block, as the socket must not be + // closed. It is passed into the GPGNetClient. + Socket socket = serverSocket.accept(); + LockUtil.executeWithLock(lockSocket, () -> { if (currentClient != null) { onGpgnetConnectionLost();