Code review comment: The argument is simple: It's been a (loose) policy all along, so if we want to change it, we should do the bare minimum of trying to figure out whether it makes sense to or not, not just put forth generic arguments that could be applied to almost any situation.

Code before review:
public Uni<WebSocketClientConnection> connect() {
if (baseUri == null) {
throw new WebSocketClientException("Endpoint URI not set!");
}
WebSocketClient client = vertx.createWebSocketClient(populateClientOptions());
WebSocketConnectOptions connectOptions = new WebSocketConnectOptions()
.setSsl(baseUri.getScheme().equals("https"))
.setHost(baseUri.getHost())
.setPort(baseUri.getPort());
StringBuilder requestUri = new StringBuilder();
String mergedPath = mergePath(baseUri.getPath(), replacePathParameters(path));
requestUri.append(mergedPath);
if (baseUri.getQuery() != null) {
requestUri.append("?").append(baseUri.getQuery());
}
connectOptions.setURI(requestUri.toString());
for (Entry<String, List<String>> e : headers.entrySet()) {
for (String val : e.getValue()) {
connectOptions.addHeader(e.getKey(), val);
}
}
subprotocols.forEach(connectOptions::addSubProtocol);
URI serverEndpointUri;
try {
serverEndpointUri = new URI(baseUri.getScheme(), baseUri.getUserInfo(), baseUri.getHost(), baseUri.getPort(),
mergedPath,
baseUri.getQuery(), baseUri.getFragment());
} catch (URISyntaxException e) {
throw new WebSocketClientException(e);
}
return Uni.createFrom().completionStage(() -> client.connect(connectOptions).toCompletionStage())
.map(ws -> {
String clientId = BasicWebSocketConnector.class.getName();
TrafficLogger trafficLogger = TrafficLogger.forClient(config);
WebSocketClientConnectionImpl connection = new WebSocketClientConnectionImpl(clientId, ws,
codecs,
pathParams,
serverEndpointUri,
headers, trafficLogger);
if (trafficLogger != null) {
trafficLogger.connectionOpened(connection);
}
connectionManager.add(BasicWebSocketConnectorImpl.class.getName(), connection);
if (openHandler != null) {
doExecute(connection, null, (c, ignored) -> openHandler.accept(c));
}
if (textMessageHandler != null) {
ws.textMessageHandler(new Handler<String>() {
@Override
public void handle(String message) {
if (trafficLogger != null) {
trafficLogger.textMessageReceived(connection, message);
}
doExecute(connection, message, textMessageHandler);
}
});
}
if (binaryMessageHandler != null) {
ws.binaryMessageHandler(new Handler<Buffer>() {
@Override
public void handle(Buffer message) {
if (trafficLogger != null) {
trafficLogger.binaryMessageReceived(connection, message);
}
doExecute(connection, message, binaryMessageHandler);
}
});
}
if (pongMessageHandler != null) {
ws.pongHandler(new Handler<Buffer>() {
@Override
public void handle(Buffer event) {
doExecute(connection, event, pongMessageHandler);
}
});
}
if (errorHandler != null) {
ws.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable event) {
doExecute(connection, event, errorHandler);
}
});
}
ws.closeHandler(new Handler<Void>() {
@Override
public void handle(Void event) {
if (trafficLogger != null) {
trafficLogger.connectionClosed(connection);
}
if (closeHandler != null) {
doExecute(connection, new CloseReason(ws.closeStatusCode(), ws.closeReason()), closeHandler);
}
connectionManager.remove(BasicWebSocketConnectorImpl.class.getName(), connection);
client.close();
}
});
return connection;
});
}

Line under review: return Uni.createFrom().completionStage(() -> client.connect(connectOptions).toCompletionStage())

Code after addressing the review:
public Uni<WebSocketClientConnection> connect() {
if (baseUri == null) {
throw new WebSocketClientException("Endpoint URI not set!");
}
WebSocketClient client = vertx.createWebSocketClient(populateClientOptions());
WebSocketConnectOptions connectOptions = new WebSocketConnectOptions()
.setSsl(baseUri.getScheme().equals("https"))
.setHost(baseUri.getHost())
.setPort(baseUri.getPort());
StringBuilder requestUri = new StringBuilder();
String mergedPath = mergePath(baseUri.getPath(), replacePathParameters(path));
requestUri.append(mergedPath);
if (baseUri.getQuery() != null) {
requestUri.append("?").append(baseUri.getQuery());
}
connectOptions.setURI(requestUri.toString());
for (Entry<String, List<String>> e : headers.entrySet()) {
for (String val : e.getValue()) {
connectOptions.addHeader(e.getKey(), val);
}
}
subprotocols.forEach(connectOptions::addSubProtocol);
URI serverEndpointUri;
try {
serverEndpointUri = new URI(baseUri.getScheme(), baseUri.getUserInfo(), baseUri.getHost(), baseUri.getPort(),
mergedPath,
baseUri.getQuery(), baseUri.getFragment());
} catch (URISyntaxException e) {
throw new WebSocketClientException(e);
}
return Uni.createFrom().completionStage(() -> client.connect(connectOptions).toCompletionStage())
.map(ws -> {
String clientId = BasicWebSocketConnector.class.getName();
TrafficLogger trafficLogger = TrafficLogger.forClient(config);
WebSocketClientConnectionImpl connection = new WebSocketClientConnectionImpl(clientId, ws,
codecs,
pathParams,
serverEndpointUri,
headers, trafficLogger);
if (trafficLogger != null) {
trafficLogger.connectionOpened(connection);
}
connectionManager.add(BasicWebSocketConnectorImpl.class.getName(), connection);
if (openHandler != null) {
doExecute(connection, null, (c, ignored) -> openHandler.accept(c));
}
if (textMessageHandler != null) {
ws.textMessageHandler(new Handler<String>() {
@Override
public void handle(String message) {
if (trafficLogger != null) {
trafficLogger.textMessageReceived(connection, message);
}
doExecute(connection, message, textMessageHandler);
}
});
}
if (binaryMessageHandler != null) {
ws.binaryMessageHandler(new Handler<Buffer>() {
@Override
public void handle(Buffer message) {
if (trafficLogger != null) {
trafficLogger.binaryMessageReceived(connection, message);
}
doExecute(connection, message, binaryMessageHandler);
}
});
}
if (pongMessageHandler != null) {
ws.pongHandler(new Handler<Buffer>() {
@Override
public void handle(Buffer event) {
doExecute(connection, event, pongMessageHandler);
}
});
}
if (errorHandler != null) {
ws.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable event) {
doExecute(connection, event, errorHandler);
}
});
}
ws.closeHandler(new Handler<Void>() {
@Override
public void handle(Void event) {
if (trafficLogger != null) {
trafficLogger.connectionClosed(connection);
}
if (closeHandler != null) {
doExecute(connection, new CloseReason(ws.closeStatusCode(), ws.closeReason()), closeHandler);
}
connectionManager.remove(BasicWebSocketConnectorImpl.class.getName(), connection);
client.close();
}
});
return connection;
});
}