Skip to content

Commit

Permalink
[shelly] Cancel the init job when the thing handler is disposed
Browse files Browse the repository at this point in the history
Fix openhab#14032

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo committed Jan 29, 2023
1 parent 178d16c commit d939dbb
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public abstract class ShellyBaseHandler extends BaseThingHandler
private int skipUpdate = 0;
private boolean refreshSettings = false;
private @Nullable ScheduledFuture<?> statusJob;
private @Nullable ScheduledFuture<?> initJob;

/**
* Constructor
Expand Down Expand Up @@ -171,7 +172,7 @@ public boolean checkRepresentation(String key) {
@Override
public void initialize() {
// start background initialization:
scheduler.schedule(() -> {
initJob = scheduler.schedule(() -> {
boolean start = true;
try {
initializeThingConfig();
Expand Down Expand Up @@ -1473,7 +1474,12 @@ public void triggerChannel(String group, String channel, String payload) {

public void stop() {
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) {
job.cancel(true);
statusJob = null;
Expand Down

0 comments on commit d939dbb

Please sign in to comment.