]> git.basschouten.com Git - openhab-addons.git/commitdiff
[openweathermap] Call Thread.currentThread().interrupt() on InterruptedException...
authorChristoph Weitkamp <github@christophweitkamp.de>
Sun, 20 Feb 2022 11:35:51 +0000 (12:35 +0100)
committerGitHub <noreply@github.com>
Sun, 20 Feb 2022 11:35:51 +0000 (12:35 +0100)
* Call Thread.currentThread().interrupt() on InterruptedException

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java
bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java

index 70e2967f2b2c7574679e6af89acc7e5210b664b2..06c547f159f7867b56bf0cee7f8f680b38d77e1d 100644 (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());
         }
index 308d04b59308d8e400f2640a83c05e72505dfb3b..ac4ed5dfdee0dcf49546303fabfe2a658c8da82d 100644 (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());
         }
     }