]> git.basschouten.com Git - openhab-addons.git/commitdiff
[nanoleaf] Stop the HTTP client when disposing the thing handler (#14459)
authorlolodomo <lg.hc@free.fr>
Mon, 20 Feb 2023 19:28:27 +0000 (20:28 +0100)
committerGitHub <noreply@github.com>
Mon, 20 Feb 2023 19:28:27 +0000 (20:28 +0100)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.nanoleaf/src/main/java/org/openhab/binding/nanoleaf/internal/handler/NanoleafControllerHandler.java

index 49953a787f6722794114028f3d0d84401662f7f2..304f9f62ab65b119bfc8865b8a69e14ec7ec0570 100644 (file)
@@ -91,6 +91,7 @@ import org.openhab.core.thing.ThingStatusDetail;
 import org.openhab.core.thing.binding.BaseBridgeHandler;
 import org.openhab.core.thing.binding.ThingHandlerCallback;
 import org.openhab.core.thing.binding.ThingHandlerService;
+import org.openhab.core.thing.util.ThingWebClientUtil;
 import org.openhab.core.types.Command;
 import org.openhab.core.types.RefreshType;
 import org.slf4j.Logger;
@@ -147,7 +148,7 @@ public class NanoleafControllerHandler extends BaseBridgeHandler implements Nano
     }
 
     private void initializeTouchHttpClient() {
-        String httpClientName = thing.getUID().getId();
+        String httpClientName = ThingWebClientUtil.buildWebClientConsumerName(thing.getUID(), null);
 
         try {
             httpClientSSETouchEvent = httpClientFactory.createHttpClient(httpClientName);
@@ -290,6 +291,14 @@ public class NanoleafControllerHandler extends BaseBridgeHandler implements Nano
     @Override
     public void dispose() {
         stopAllJobs();
+        HttpClient localHttpClientSSETouchEvent = this.httpClientSSETouchEvent;
+        if (localHttpClientSSETouchEvent != null) {
+            try {
+                localHttpClientSSETouchEvent.stop();
+            } catch (Exception e) {
+            }
+            this.httpClientSSETouchEvent = null;
+        }
         super.dispose();
         logger.debug("Disposing handler for Nanoleaf controller {}", getThing().getUID());
     }