From fcfdefec389ede05354889473d4f2da482822c49 Mon Sep 17 00:00:00 2001 From: Markus Rathgeb Date: Mon, 9 Mar 2015 09:15:07 +0100 Subject: [PATCH] Resource leak: 'socket' never closed Signed-off-by: Markus Rathgeb --- .../src/main/java/org/openhab/io/net/actions/Ping.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; } }