yet another attempt to skip client connection attempts for non-existing socket files

This commit is contained in:
Sebastian Stenzel
2021-07-14 15:07:13 +02:00
parent 03182ae4e0
commit 87d481ccc3
2 changed files with 4 additions and 3 deletions

View File

@@ -22,8 +22,6 @@ class Client implements IpcCommunicator {
}
public static Client create(Path socketPath) throws IOException {
// fail with NoSuchFileException early to prevent implicit creation of socket on Windows:
socketPath.getFileSystem().provider().checkAccess(socketPath);
var address = UnixDomainSocketAddress.of(socketPath);
var socketChannel = SocketChannel.open(address);
LOG.info("Connected to IPC server on UNIX socket {}", socketPath);

View File

@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.Executor;
@@ -31,7 +32,9 @@ public interface IpcCommunicator extends Closeable {
Preconditions.checkArgument(socketPaths.iterator().hasNext(), "socketPaths must contain at least one element");
for (var p : socketPaths) {
try {
return Client.create(p);
if (Files.exists(p)) {
return Client.create(p);
}
} catch (IOException e) {
// attempt next socket path
}