[freebox] Fix handling of InterruptedException (Thread.sleep) (#10462)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
80ffaeec7b
commit
fbea2f3535
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue