gnodet-bot commented on code in PR #29221:
URL: https://github.com/apache/camel/pull/29221#discussion_r4478573685


##########
components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/VertxPlatformHttpServer.java:
##########
@@ -254,6 +254,14 @@ protected void startServer() throws Exception {
                     }
                 },
                 executor).toCompletableFuture().join();
+
+        Throwable cause = failure.get();
+        if (cause != null) {
+            throw new RuntimeCamelException(
+                    "Failed to start Vert.x HttpServer on " + 
configuration.getBindHost() + ":" + configuration.getBindPort()
+                                            + ", reason: " + 
cause.getMessage(),

Review Comment:
   ⚠️ `cause.getMessage()` on the rethrow path may return `null`
   
   `Throwable.getMessage()` can return `null` — `BindException` is constructed 
with just an address string on most JVMs, so in practice the message is there, 
but it is not guaranteed. When null, the error message reads `"…, reason: 
null"`, which is non-actionable for the user.
   
   ```suggestion
                       "Failed to start Vert.x HttpServer on " + 
configuration.getBindHost() + ":" + configuration.getBindPort()
                                               + ", reason: " + 
(cause.getMessage() != null ? cause.getMessage() : 
cause.getClass().getSimpleName()),
   ```
   
   Or more simply, `cause.toString()` already includes the class name and 
message (e.g. `"java.net.BindException: Address already in use"`), which is 
both always non-null and more informative:
   
   ```suggestion
                       "Failed to start Vert.x HttpServer on " + 
configuration.getBindHost() + ":" + configuration.getBindPort()
                                               + ", reason: " + cause,
   ```



-- 
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]

Reply via email to