davsclaus commented on code in PR #24740:
URL: https://github.com/apache/camel/pull/24740#discussion_r3589025820
##########
components/camel-vertx/camel-vertx-websocket/src/main/java/org/apache/camel/component/vertx/websocket/VertxWebsocketEndpoint.java:
##########
@@ -171,8 +181,12 @@ protected WebSocket getWebSocket() throws Exception {
CompletableFuture<WebSocket> future = new CompletableFuture<>();
client.connect(connectOptions).onComplete(result -> {
if (result.succeeded()) {
- LOG.info("Connected to WebSocket on {}",
result.result().remoteAddress());
- future.complete(result.result());
+ WebSocket ws = result.result();
+ LOG.info("Connected to WebSocket on {}",
ws.remoteAddress());
+ if (setupCallback != null) {
+ setupCallback.accept(ws);
+ }
+ future.complete(ws);
Review Comment:
Minor robustness suggestion: if `setupCallback.accept(ws)` throws,
`future.complete(ws)` is never reached and the caller gets a `TimeoutException`
rather than the real cause. Consider:
```suggestion
if (setupCallback != null) {
try {
setupCallback.accept(ws);
} catch (Exception e) {
future.completeExceptionally(e);
return;
}
}
```
Low-risk in practice since `configureWebSocketHandlers` only calls handler
setters, but would help debugging if this pattern is reused elsewhere.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]