Skip to content

Commit

Permalink
WebSockets Next: avoid possible data race in a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Apr 22, 2024
1 parent 824234e commit 03072d9
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public WSClient connect(WebSocketConnectOptions options, URI url) {
if (url.getQuery() != null) {
uri.append("?").append(url.getQuery());
}
WebSocket webSocket = await(
client.connect(options.setPort(url.getPort()).setHost(url.getHost()).setURI(uri.toString())));
WebSocket webSocket = client.webSocket();
webSocket.handler(b -> messages.add(b));
await(client.connect(options.setPort(url.getPort()).setHost(url.getHost()).setURI(uri.toString())));
var prev = socket.getAndSet(webSocket);
if (prev != null) {
messages.clear();
await(prev.close());
}
webSocket.handler(b -> messages.add(b));
return this;
}

Expand Down

0 comments on commit 03072d9

Please sign in to comment.