Remove IPC socket before creation (#1852)

(to make sure that socket path can be created)
This commit is contained in:
Bart
2021-10-25 09:47:02 +02:00
committed by GitHub
parent 28d2262962
commit 520b3a8f08

View File

@@ -44,7 +44,9 @@ public interface IpcCommunicator extends Closeable {
}
// Didn't get any connection yet? I.e. we're the first app instance, so let's launch a server:
try {
return Server.create(socketPaths.iterator().next());
final var socketPath = socketPaths.iterator().next();
Files.deleteIfExists(socketPath); // ensure path does not exist before creating it
return Server.create(socketPath);
} catch (IOException e) {
LOG.warn("Failed to create IPC server", e);
return new LoopbackCommunicator();