Skip to content

Commit

Permalink
chore: makes HttpClient instance available for garbage collection (#2…
Browse files Browse the repository at this point in the history
…0746) (#20748)

Allows the HttpClient default executor to be properly shutdown when HttpClient
is not referenced anymore.

Co-authored-by: Marco Collovati <[email protected]>
  • Loading branch information
vaadin-bot and mcollovati authored Dec 19, 2024
1 parent 032aef5 commit 9112e10
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class ViteWebsocketConnection implements Listener {

private final Consumer<String> onMessage;
private final Runnable onClose;
private final CompletableFuture<WebSocket> clientWebsocket = new CompletableFuture<>();
private final List<CharSequence> parts = new ArrayList<>();
private CompletableFuture<WebSocket> clientWebsocket = new CompletableFuture<>();

private static Logger getLogger() {
return LoggerFactory.getLogger(ViteWebsocketConnection.class);
Expand Down Expand Up @@ -169,6 +169,9 @@ public void close() throws InterruptedException, ExecutionException {
// Websocket client connection has not been established
clientWebsocket.cancel(true);
}
// release HttpClient reference, so its internal executor can be
// properly stopped
clientWebsocket = null;
}

@Override
Expand Down

0 comments on commit 9112e10

Please sign in to comment.