diff --git a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/actions/Ping.java b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/actions/Ping.java index 5d939feea7f0e..bbc5294bbb118 100644 --- a/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/actions/Ping.java +++ b/bundles/core/org.openhab.core.compat1x/src/main/java/org/openhab/io/net/actions/Ping.java @@ -50,9 +50,11 @@ public static boolean checkVitality(String host, int port, int timeout) throws I } else { SocketAddress socketAddress = new InetSocketAddress(host, port); - - Socket socket = new Socket(); - socket.connect(socketAddress, timeout); + + try (Socket socket = new Socket()) { + socket.connect(socketAddress, timeout); + } + success = true; } }