]> git.basschouten.com Git - openhab-addons.git/commitdiff
[freebox] Fix handling of InterruptedException (Thread.sleep) (#10462)
authorlolodomo <lg.hc@free.fr>
Mon, 5 Apr 2021 13:13:38 +0000 (15:13 +0200)
committerGitHub <noreply@github.com>
Mon, 5 Apr 2021 13:13:38 +0000 (15:13 +0200)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/api/FreeboxApiManager.java
bundles/org.openhab.binding.freebox/src/main/java/org/openhab/binding/freebox/internal/handler/FreeboxHandler.java

index e90294af8e8f07ad7f5f4d284b8c000c32b300fe..c2b84ad9e6250a5a93227d9b569a95c8806bee83 100644 (file)
@@ -121,7 +121,8 @@ public class FreeboxApiManager {
         }
     }
 
-    public boolean authorize(boolean useHttps, String fqdn, String apiBaseUrl, String apiVersion, String appToken) {
+    public boolean authorize(boolean useHttps, String fqdn, String apiBaseUrl, String apiVersion, String appToken)
+            throws InterruptedException {
         String[] versionSplit = apiVersion.split("\\.");
         String majorVersion = "5";
         if (versionSplit.length > 0) {
@@ -155,7 +156,7 @@ public class FreeboxApiManager {
             this.appToken = token;
             openSession();
             return true;
-        } catch (FreeboxException | InterruptedException e) {
+        } catch (FreeboxException e) {
             logger.debug("Error while opening a session", e);
             return false;
         }
index f0a48f8baffd85cea497c7e9e83b4aba08461553..5fe71a3f5efe21488e91289297ecfba628dde6dd 100644 (file)
@@ -158,7 +158,13 @@ public class FreeboxHandler extends BaseBridgeHandler {
 
             logger.debug("Binding will schedule a job to establish a connection...");
             if (authorizeJob == null || authorizeJob.isCancelled()) {
-                authorizeJob = scheduler.schedule(this::authorize, 1, TimeUnit.SECONDS);
+                authorizeJob = scheduler.schedule(() -> {
+                    try {
+                        authorize();
+                    } catch (InterruptedException e) {
+                        Thread.currentThread().interrupt();
+                    }
+                }, 1, TimeUnit.SECONDS);
             }
         } else {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
@@ -196,7 +202,7 @@ public class FreeboxHandler extends BaseBridgeHandler {
         }
     }
 
-    private void authorize() {
+    private void authorize() throws InterruptedException {
         logger.debug("Authorize job...");
 
         String fqdn = configuration.fqdn;