]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fix NullPointerException (#15259)
authorJacob Laursen <jacob-github@vindvejr.dk>
Mon, 17 Jul 2023 15:04:04 +0000 (17:04 +0200)
committerGitHub <noreply@github.com>
Mon, 17 Jul 2023 15:04:04 +0000 (17:04 +0200)
Fixes #15256

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.samsungtv/src/main/java/org/openhab/binding/samsungtv/internal/service/MainTVServerService.java

index 066b8f14081a15f2d60e2bb9e134263d5cb91c30..395769783f52c3ba5a779bd269f9406a94ad5043 100644 (file)
@@ -229,23 +229,25 @@ public class MainTVServerService implements UpnpIOParticipant, SamsungTvService
         String source = command.toString();
         String id = null;
 
-        if (result.get("Result").equals("OK")) {
+        String resultResult = result.get("Result");
+        if ("OK".equals(resultResult)) {
             String xml = result.get("SourceList");
             if (xml != null) {
                 id = parseSourceList(xml).get(source);
             }
         } else {
-            logger.warn("Source list query failed, result='{}'", result.get("Result"));
+            logger.warn("Source list query failed, result='{}'", resultResult);
         }
 
         if (source != null && id != null) {
             result = updateResourceState("MainTVAgent2", "SetMainTVSource",
                     SamsungTvUtils.buildHashMap("Source", source, "ID", id, "UiID", "0"));
 
-            if (result.get("Result").equals("OK")) {
+            resultResult = result.get("Result");
+            if ("OK".equals(resultResult)) {
                 logger.debug("Command successfully executed");
             } else {
-                logger.warn("Command execution failed, result='{}'", result.get("Result"));
+                logger.warn("Command execution failed, result='{}'", resultResult);
             }
         } else {
             logger.warn("Source id for '{}' couldn't be found", command.toString());
@@ -256,20 +258,22 @@ public class MainTVServerService implements UpnpIOParticipant, SamsungTvService
         Map<String, String> result = updateResourceState("MainTVAgent2", "RunBrowser",
                 SamsungTvUtils.buildHashMap("BrowserURL", command.toString()));
 
-        if (result.get("Result").equals("OK")) {
+        String resultResult = result.get("Result");
+        if ("OK".equals(resultResult)) {
             logger.debug("Command successfully executed");
         } else {
-            logger.warn("Command execution failed, result='{}'", result.get("Result"));
+            logger.warn("Command execution failed, result='{}'", resultResult);
         }
     }
 
     private void stopBrowser(Command command) {
         Map<String, String> result = updateResourceState("MainTVAgent2", "StopBrowser", null);
 
-        if (result.get("Result").equals("OK")) {
+        String resultResult = result.get("Result");
+        if ("OK".equals(resultResult)) {
             logger.debug("Command successfully executed");
         } else {
-            logger.warn("Command execution failed, result='{}'", result.get("Result"));
+            logger.warn("Command execution failed, result='{}'", resultResult);
         }
     }