[openweathermap] Call Thread.currentThread().interrupt() on InterruptedException (#12314)

* Call Thread.currentThread().interrupt() on InterruptedException

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2022-02-20 12:35:51 +01:00 committed by GitHub
parent 9bb43461fb
commit a517e6e768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -428,9 +428,15 @@ public class OpenWeatherMapConnection {
throw new CommunicationException(
errorMessage == null ? "@text/offline.communication-error" : errorMessage, e.getCause());
}
} catch (InterruptedException | TimeoutException e) {
} catch (TimeoutException e) {
String errorMessage = e.getMessage();
logger.debug("InterruptedException or TimeoutException occurred during execution: {}", errorMessage, e);
logger.debug("TimeoutException occurred during execution: {}", errorMessage, e);
throw new CommunicationException(errorMessage == null ? "@text/offline.communication-error" : errorMessage,
e.getCause());
} catch (InterruptedException e) {
String errorMessage = e.getMessage();
logger.debug("InterruptedException occurred during execution: {}", errorMessage, e);
Thread.currentThread().interrupt();
throw new CommunicationException(errorMessage == null ? "@text/offline.communication-error" : errorMessage,
e.getCause());
}

View File

@ -138,9 +138,9 @@ public abstract class AbstractOpenWeatherMapHandler extends BaseThingHandler {
updateStatus(ThingStatus.ONLINE);
}
} catch (CommunicationException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getLocalizedMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getRawMessage());
} catch (ConfigurationException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getLocalizedMessage());
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getRawMessage());
}
}