From 3d8834cbebf612ed6c5d26da8c79ba544169da0b Mon Sep 17 00:00:00 2001 From: druciak Date: Fri, 4 Aug 2017 03:54:46 +0200 Subject: [PATCH] [Satel] Binding deactivation fix (#5207) --- .../satel/internal/protocol/SatelModule.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bundles/binding/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/SatelModule.java b/bundles/binding/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/SatelModule.java index 56f642cd265..c7cbc4f5be7 100644 --- a/bundles/binding/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/SatelModule.java +++ b/bundles/binding/org.openhab.binding.satel/src/main/java/org/openhab/binding/satel/internal/protocol/SatelModule.java @@ -154,10 +154,20 @@ public synchronized void open() { * Stops communication by disconnecting from the module and stopping all * background tasks. */ - public synchronized void close() { + public void close() { + // first we clear watchdog field in the object + CommunicationWatchdog watchdog = null; if (this.communicationWatchdog != null) { - this.communicationWatchdog.close(); - this.communicationWatchdog = null; + synchronized (this) { + if (this.communicationWatchdog != null) { + watchdog = this.communicationWatchdog; + this.communicationWatchdog = null; + } + } + } + // then, if watchdog exists, we close it + if (watchdog != null) { + watchdog.close(); } }