diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/service/WatchQueueReader.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/service/WatchQueueReader.java index 6671c83b4f5..bde432db685 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/service/WatchQueueReader.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/service/WatchQueueReader.java @@ -203,15 +203,10 @@ public synchronized void stopWatchService(AbstractWatchService service) { @Override public void run() { - try { - for (;;) { + while (!Thread.currentThread().isInterrupted()) { + try { WatchKey key; - try { - key = watchService.take(); - } catch (InterruptedException exc) { - logger.info("Caught InterruptedException: {}", exc.getLocalizedMessage()); - return; - } + key = watchService.take(); for (WatchEvent event : key.pollEvents()) { WatchEvent.Kind kind = event.kind(); @@ -273,11 +268,12 @@ public void run() { } key.reset(); + } catch (InterruptedException exc) { + logger.debug("WatchQueueReader interrupted; thread exiting: {}", exc.getLocalizedMessage()); + return; + } catch (Exception exc) { + logger.debug("Exception caught in WatchQueueReader", exc); } - } catch (Exception exc) { - logger.debug("ClosedWatchServiceException caught! {}. \n{} Stopping ", exc.getLocalizedMessage(), - Thread.currentThread().getName()); - return; } }