Skip to content

Commit

Permalink
[innogysmarthome] Fix possible resource leak
Browse files Browse the repository at this point in the history
Related to #8027

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo committed Jul 5, 2020
1 parent eba4892 commit 55a0485
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package org.openhab.binding.innogysmarthome.internal;

import java.io.IOException;
import java.net.URI;

import org.eclipse.jdt.annotation.NonNullByDefault;
Expand Down Expand Up @@ -73,7 +74,11 @@ public synchronized void start() throws Exception {
if (client == null || client.isStopped()) {
client = new WebSocketClient(sslContextFactory);
client.setMaxIdleTimeout(this.maxIdleTimeout);
client.start();
try {
client.start();
} catch (Exception e) {
throw new IOException("Web socket start failed");
}
}

if (session != null) {
Expand All @@ -97,6 +102,15 @@ public synchronized void stop() {
session = null;
logger.trace("Stopping websocket ignored - was not running.");
}
if (client != null) {
try {
client.stop();
client.destroy();
} catch (Exception e) {
logger.debug("Stopping websocket failed", e);
}
client = null;
}
}

/**
Expand Down

0 comments on commit 55a0485

Please sign in to comment.