[somfytahoma] Fix code analysis warnings (#10466)

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2021-04-05 15:01:17 +02:00 committed by GitHub
parent 6e44b1ca15
commit 782fe0eb8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -252,20 +252,20 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
} catch (JsonSyntaxException e) { } catch (JsonSyntaxException e) {
logger.debug("Received invalid data (login)", e); logger.debug("Received invalid data (login)", e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Received invalid data (login)"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Received invalid data (login)");
} catch (InterruptedException | ExecutionException | TimeoutException e) { } catch (ExecutionException e) {
if (e instanceof ExecutionException) {
if (isAuthenticationChallenge(e)) { if (isAuthenticationChallenge(e)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Authentication challenge");
"Authentication challenge");
setTooManyRequests(); setTooManyRequests();
return; } else {
} logger.debug("Cannot get login cookie", e);
}
logger.debug("Cannot get login cookie!", e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Cannot get login cookie"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Cannot get login cookie");
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt();
} }
} 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,13 +592,12 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
try { try {
eventsId = ""; eventsId = "";
sendGetToTahomaWithCookie(TAHOMA_API_URL + "logout"); sendGetToTahomaWithCookie(TAHOMA_API_URL + "logout");
} catch (InterruptedException | ExecutionException | TimeoutException e) { } catch (ExecutionException | TimeoutException e) {
logger.debug("Cannot send logout command!", e); logger.debug("Cannot send logout command!", e);
if (e instanceof InterruptedException) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
}
private String sendPostToTahomaWithCookie(String url, String urlParameters) private String sendPostToTahomaWithCookie(String url, String urlParameters)
throws InterruptedException, ExecutionException, TimeoutException { throws InterruptedException, ExecutionException, TimeoutException {
@ -845,13 +844,13 @@ public class SomfyTahomaBridgeHandler extends BaseBridgeHandler {
logger.debug("Cannot call url: {} with params: {}!", url, urlParameters, e); logger.debug("Cannot call url: {} with params: {}!", url, urlParameters, e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
} }
} catch (InterruptedException | TimeoutException e) { } catch (TimeoutException e) {
logger.debug("Cannot call url: {} with params: {}!", url, urlParameters, e); logger.debug("Timeout when calling url: {} with params: {}!", url, urlParameters, e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
} catch (InterruptedException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
if (e instanceof InterruptedException) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
}
return null; return null;
} }
} }