]> git.basschouten.com Git - openhab-addons.git/commitdiff
[lgwebos] fix NPE (#8995)
authorJ-N-K <J-N-K@users.noreply.github.com>
Tue, 10 Nov 2020 07:42:03 +0000 (08:42 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Nov 2020 07:42:03 +0000 (23:42 -0800)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
bundles/org.openhab.binding.lgwebos/src/main/java/org/openhab/binding/lgwebos/internal/WakeOnLanUtility.java

index 913e8230665125e694aadf33c17ddefb124b6ed1..5cb1497e08d451ae4272a9a0dfbd957d20d7ace8 100644 (file)
@@ -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 {