mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[nanoleaf] Stop the HTTP client when disposing the thing handler (#14459)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
1f877cae6d
commit
d33f6916d2
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user