From a517e6e768df787b6ccb4848c495b81db1159e99 Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Sun, 20 Feb 2022 12:35:51 +0100 Subject: [PATCH] [openweathermap] Call Thread.currentThread().interrupt() on InterruptedException (#12314) * Call Thread.currentThread().interrupt() on InterruptedException Signed-off-by: Christoph Weitkamp --- .../internal/connection/OpenWeatherMapConnection.java | 10 ++++++++-- .../handler/AbstractOpenWeatherMapHandler.java | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java index 70e2967f2..06c547f15 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java @@ -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()); } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java index 308d04b59..ac4ed5dfd 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java @@ -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()); } }