Skip to content

Commit

Permalink
[shelly] Cancel the init job when the thing handler is disposed (open…
Browse files Browse the repository at this point in the history
…hab#14290)

Fix openhab#14032

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo authored and psmedley committed Feb 23, 2023
1 parent ab5fadf commit e22a46a
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 e22a46a

Please sign in to comment.