[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.BaseBridgeHandler;
|
||||||
import org.openhab.core.thing.binding.ThingHandlerCallback;
|
import org.openhab.core.thing.binding.ThingHandlerCallback;
|
||||||
import org.openhab.core.thing.binding.ThingHandlerService;
|
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.Command;
|
||||||
import org.openhab.core.types.RefreshType;
|
import org.openhab.core.types.RefreshType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -147,7 +148,7 @@ public class NanoleafControllerHandler extends BaseBridgeHandler implements Nano
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTouchHttpClient() {
|
private void initializeTouchHttpClient() {
|
||||||
String httpClientName = thing.getUID().getId();
|
String httpClientName = ThingWebClientUtil.buildWebClientConsumerName(thing.getUID(), null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
httpClientSSETouchEvent = httpClientFactory.createHttpClient(httpClientName);
|
httpClientSSETouchEvent = httpClientFactory.createHttpClient(httpClientName);
|
||||||
@ -290,6 +291,14 @@ public class NanoleafControllerHandler extends BaseBridgeHandler implements Nano
|
|||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
stopAllJobs();
|
stopAllJobs();
|
||||||
|
HttpClient localHttpClientSSETouchEvent = this.httpClientSSETouchEvent;
|
||||||
|
if (localHttpClientSSETouchEvent != null) {
|
||||||
|
try {
|
||||||
|
localHttpClientSSETouchEvent.stop();
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
this.httpClientSSETouchEvent = null;
|
||||||
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
logger.debug("Disposing handler for Nanoleaf controller {}", getThing().getUID());
|
logger.debug("Disposing handler for Nanoleaf controller {}", getThing().getUID());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user