Use try-with-resources or close this "AFUNIXServerSocket" in a "finally" clause
@@ -18,16 +18,18 @@ public class DefaultUnixSocketFactory implements UnixSocketFactory {
@Override
public ServerSocket createServerSocket(final Path socketFile) throws IOException {
- final ServerSocket server = AFUNIXServerSocket.newInstance();
+ try (final ServerSocket server = AFUNIXServerSocket.newInstance()) {
server.bind(new AFUNIXSocketAddress(socketFile.toFile()));
return server;
}
+ }
@Override
public Socket createSocket(final Path socketFile) throws IOException {
- final Socket socket = AFUNIXSocket.newInstance();
+ try (final Socket socket = AFUNIXSocket.newInstance()) {
socket.connect(new AFUNIXSocketAddress(socketFile.toFile()));
return socket;
}
+ }
}
