diff --git a/bundles/org.openhab.binding.bosesoundtouch/pom.xml b/bundles/org.openhab.binding.bosesoundtouch/pom.xml index cada48d0ed878..d456c1cee955e 100644 --- a/bundles/org.openhab.binding.bosesoundtouch/pom.xml +++ b/bundles/org.openhab.binding.bosesoundtouch/pom.xml @@ -1,4 +1,6 @@ - + + 4.0.0 diff --git a/bundles/org.openhab.binding.bosesoundtouch/src/main/java/org/openhab/binding/bosesoundtouch/internal/handler/BoseSoundTouchHandler.java b/bundles/org.openhab.binding.bosesoundtouch/src/main/java/org/openhab/binding/bosesoundtouch/internal/handler/BoseSoundTouchHandler.java index 49fc0a5029043..e3bf139c956c7 100644 --- a/bundles/org.openhab.binding.bosesoundtouch/src/main/java/org/openhab/binding/bosesoundtouch/internal/handler/BoseSoundTouchHandler.java +++ b/bundles/org.openhab.binding.bosesoundtouch/src/main/java/org/openhab/binding/bosesoundtouch/internal/handler/BoseSoundTouchHandler.java @@ -21,6 +21,7 @@ import java.util.Comparator; import java.util.List; import java.util.Objects; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -93,6 +94,8 @@ public class BoseSoundTouchHandler extends BaseThingHandler implements WebSocket private PresetContainer presetContainer; private BoseStateDescriptionOptionProvider stateOptionProvider; + private Future sessionFuture; + /** * Creates a new instance of this class for the {@link Thing}. * @@ -423,7 +426,7 @@ private synchronized void openConnection() { request.setSubProtocols("gabbo"); client.setStopTimeout(1000); client.start(); - client.connect(this, new URI(wsUrl), request); + sessionFuture = client.connect(this, new URI(wsUrl), request); } catch (Exception e) { onWebSocketError(e); } @@ -439,7 +442,10 @@ private synchronized void closeConnection() { } session = null; } - if (client != null) { + if (sessionFuture != null && !sessionFuture.isDone()) { + sessionFuture.cancel(true); + } + if (client != null && client.isStarted()) { try { client.stop(); client.destroy();