]> git.basschouten.com Git - openhab-addons.git/commitdiff
[somfytahoma] Fix code analysis warnings (#10466)
authorlolodomo <lg.hc@free.fr>
Mon, 5 Apr 2021 13:01:17 +0000 (15:01 +0200)
committerGitHub <noreply@github.com>
Mon, 5 Apr 2021 13:01:17 +0000 (15:01 +0200)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.somfytahoma/src/main/java/org/openhab/binding/somfytahoma/internal/handler/SomfyTahomaBridgeHandler.java

index 8bfdd12c1bc920e745a45b92daba7308abe6c521..daa3b4c417d6dac1d6284e0a81e9a4d0a4f421ac 100644 (file)
@@ -252,20 +252,20 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
         } catch (JsonSyntaxException e) {
             logger.debug("Received invalid data (login)", e);
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Received invalid data (login)");
-        } catch (InterruptedException | ExecutionException | TimeoutException e) {
-            if (e instanceof ExecutionException) {
-                if (isAuthenticationChallenge(e)) {
-                    updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
-                            "Authentication challenge");
-                    setTooManyRequests();
-                    return;
-                }
-            }
-            logger.debug("Cannot get login cookie!", e);
-            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Cannot get login cookie");
-            if (e instanceof InterruptedException) {
-                Thread.currentThread().interrupt();
+        } catch (ExecutionException e) {
+            if (isAuthenticationChallenge(e)) {
+                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Authentication challenge");
+                setTooManyRequests();
+            } else {
+                logger.debug("Cannot get login cookie", e);
+                updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Cannot get login cookie");
             }
+        } catch (TimeoutException e) {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Getting login cookie timeout");
+        } catch (InterruptedException e) {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
+                    "Getting login cookie interrupted");
+            Thread.currentThread().interrupt();
         }
     }
 
@@ -592,11 +592,10 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
         try {
             eventsId = "";
             sendGetToTahomaWithCookie(TAHOMA_API_URL + "logout");
-        } catch (InterruptedException | ExecutionException | TimeoutException e) {
+        } catch (ExecutionException | TimeoutException e) {
             logger.debug("Cannot send logout command!", e);
-            if (e instanceof InterruptedException) {
-                Thread.currentThread().interrupt();
-            }
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
         }
     }
 
@@ -845,12 +844,12 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
                 logger.debug("Cannot call url: {} with params: {}!", url, urlParameters, e);
                 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
             }
-        } catch (InterruptedException | TimeoutException e) {
-            logger.debug("Cannot call url: {} with params: {}!", url, urlParameters, e);
+        } catch (TimeoutException e) {
+            logger.debug("Timeout when calling url: {} with params: {}!", url, urlParameters, e);
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
-            if (e instanceof InterruptedException) {
-                Thread.currentThread().interrupt();
-            }
+        } catch (InterruptedException e) {
+            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
+            Thread.currentThread().interrupt();
         }
         return null;
     }