Skip to content

Commit 338d863

Browse files
committed
Remove web socket handler when shutting down Olog ui
1 parent da4ac48 commit 338d863

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogbookSearchController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ private void cancelPeriodSearch() {
175175
* Utility method to cancel any ongoing periodic search jobs or close web socket.
176176
*/
177177
public void shutdown() {
178-
if (webSocketClientService != null) {
178+
if (connectivityModeObjectProperty.get().equals(ConnectivityMode.WEB_SOCKETS_SUPPORTED) && webSocketClientService != null) {
179179
Logger.getLogger(LogbookSearchController.class.getName()).log(Level.INFO, "Shutting down web socket");
180+
webSocketClientService.removeWebSocketMessageHandler(this);
180181
webSocketClientService.shutdown();
181182
}
182183
if(connectivityModeObjectProperty.get().equals(ConnectivityMode.HTTP_ONLY)){

core/websocket/src/main/java/org/phoebus/core/websocket/springframework/WebSocketClientService.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.springframework.web.socket.messaging.WebSocketStompClient;
2020

2121
import java.lang.reflect.Type;
22-
import java.net.URI;
2322
import java.util.ArrayList;
2423
import java.util.Collections;
2524
import java.util.List;
@@ -59,15 +58,15 @@ public class WebSocketClientService {
5958
/**
6059
* Full path to the web socket connection URL, e.g. ws://localhost:8080/Olog/web-socket
6160
*/
62-
private String connectUrl;
61+
private final String connectUrl;
6362
/**
6463
* Subscription endpoint, e.g. /Olog/web-socket/messages
6564
*/
66-
private String subscriptionEndpoint;
65+
private final String subscriptionEndpoint;
6766
/**
6867
* Echo endpoint /Olog/web-socket/echo
6968
*/
70-
private String echoEndpoint;
69+
private final String echoEndpoint;
7170

7271
private static final Logger logger = Logger.getLogger(WebSocketClientService.class.getName());
7372

@@ -82,12 +81,12 @@ public WebSocketClientService(String connectUrl, String subscriptionEndpoint, St
8281
}
8382

8483
/**
85-
* @param connectCallback The non-null method called when connection to the remote web socket has been successfully established.
86-
* @param disconnectCallback The non-null method called when connection to the remote web socket has been lost, e.g.
87-
* remote peer has been shut down.
88-
* @param connectUrl URL to the service web socket, e.g. ws://localhost:8080/Olog/web.socket
84+
* @param connectCallback The non-null method called when connection to the remote web socket has been successfully established.
85+
* @param disconnectCallback The non-null method called when connection to the remote web socket has been lost, e.g.
86+
* remote peer has been shut down.
87+
* @param connectUrl URL to the service web socket, e.g. ws://localhost:8080/Olog/web.socket
8988
* @param subscriptionEndpoint E.g. /Olog/web-socket/messages
90-
* @param echoEndpoint E.g. /Olog/web-socket/echo. May be <code>null</code> if client has no need for echo messages.
89+
* @param echoEndpoint E.g. /Olog/web-socket/echo. May be <code>null</code> if client has no need for echo messages.
9190
*/
9291
public WebSocketClientService(Runnable connectCallback, Runnable disconnectCallback, String connectUrl, String subscriptionEndpoint, String echoEndpoint) {
9392
this(connectUrl, subscriptionEndpoint, echoEndpoint);

0 commit comments

Comments
 (0)