[shelly] Cancel the init job when the thing handler is disposed (#14290)
Fix #14032 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
bf105008a1
commit
9a0d0ba409
|
@ -119,6 +119,7 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
|
||||||
private int skipUpdate = 0;
|
private int skipUpdate = 0;
|
||||||
private boolean refreshSettings = false;
|
private boolean refreshSettings = false;
|
||||||
private @Nullable ScheduledFuture<?> statusJob;
|
private @Nullable ScheduledFuture<?> statusJob;
|
||||||
|
private @Nullable ScheduledFuture<?> initJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -171,7 +172,7 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
// start background initialization:
|
// start background initialization:
|
||||||
scheduler.schedule(() -> {
|
initJob = scheduler.schedule(() -> {
|
||||||
boolean start = true;
|
boolean start = true;
|
||||||
try {
|
try {
|
||||||
initializeThingConfig();
|
initializeThingConfig();
|
||||||
|
@ -1473,7 +1474,12 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
logger.debug("{}: Shutting down", thingName);
|
logger.debug("{}: Shutting down", thingName);
|
||||||
ScheduledFuture<?> job = this.statusJob;
|
ScheduledFuture<?> job = this.initJob;
|
||||||
|
if (job != null) {
|
||||||
|
job.cancel(true);
|
||||||
|
initJob = null;
|
||||||
|
}
|
||||||
|
job = this.statusJob;
|
||||||
if (job != null) {
|
if (job != null) {
|
||||||
job.cancel(true);
|
job.cancel(true);
|
||||||
statusJob = null;
|
statusJob = null;
|
||||||
|
|
Loading…
Reference in New Issue