]> git.basschouten.com Git - openhab-addons.git/commitdiff
Prevent errors in log when URI host is null (#11893)
authorChristoph Weitkamp <github@christophweitkamp.de>
Thu, 30 Dec 2021 12:53:24 +0000 (13:53 +0100)
committerGitHub <noreply@github.com>
Thu, 30 Dec 2021 12:53:24 +0000 (13:53 +0100)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
bundles/org.openhab.binding.chromecast/src/main/java/org/openhab/binding/chromecast/internal/ChromecastStatusUpdater.java

index 1ce09bf5c69b64ff2504e9cb66b988186f9bfbc5..3eccf322912fa07aea0748f58fb1ff5e4744a2eb 100644 (file)
@@ -267,11 +267,17 @@ public class ChromecastStatusUpdater {
 
     private @Nullable RawType downloadImage(String url) {
         logger.debug("Trying to download the content of URL '{}'", url);
-        RawType downloadedImage = HttpUtil.downloadImage(url);
-        if (downloadedImage == null) {
-            logger.debug("Failed to download the content of URL '{}'", url);
+        try {
+            RawType downloadedImage = HttpUtil.downloadImage(url);
+            if (downloadedImage == null) {
+                logger.debug("Failed to download the content of URL '{}'", url);
+            }
+            return downloadedImage;
+        } catch (IllegalArgumentException e) {
+            // we catch this exception to avoid confusion errors in the log file
+            // see https://github.com/openhab/openhab-core/issues/2494#issuecomment-970162025
         }
-        return downloadedImage;
+        return null;
     }
 
     private @Nullable RawType downloadImageFromCache(String url) {