From 132f05bba50343d6c3270e2af7223c430de98cda Mon Sep 17 00:00:00 2001 From: J-N-K Date: Tue, 10 Nov 2020 08:42:03 +0100 Subject: [PATCH] [lgwebos] fix NPE (#8995) Signed-off-by: Jan N. Klug --- .../lgwebos/internal/WakeOnLanUtility.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/WakeOnLanUtility.java b/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/WakeOnLanUtility.java index 913e82306..5cb1497e0 100644 --- a/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/WakeOnLanUtility.java +++ b/bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/WakeOnLanUtility.java @@ -77,18 +77,19 @@ public class WakeOnLanUtility { String[] cmds = Stream.of(COMMAND.split(" ")).map(arg -> String.format(arg, hostName)).toArray(String[]::new); String response = ExecUtil.executeCommandLineAndWaitResponse(Duration.ofMillis(CMD_TIMEOUT_MS), cmds); - Matcher matcher = MAC_REGEX.matcher(response); String macAddress = null; - while (matcher.find()) { - String group = matcher.group(); + if (response != null) { + Matcher matcher = MAC_REGEX.matcher(response); + while (matcher.find()) { + String group = matcher.group(); - if (group.length() == 17) { - macAddress = group; - break; + if (group.length() == 17) { + macAddress = group; + break; + } } } - if (macAddress != null) { LOGGER.debug("MAC address of host {} is {}", hostName, macAddress); } else {