You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/04/13 08:01:46 UTC

[GitHub] [kafka] tombentley commented on a change in pull request #10530: KAFKA-10231 fail bootstrap of Rest server if the host name in the adv…

tombentley commented on a change in pull request #10530:
URL: https://github.com/apache/kafka/pull/10530#discussion_r612219113



##########
File path: connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/RestServer.java
##########
@@ -369,9 +370,31 @@ else if (serverConnector != null && serverConnector.getHost() != null && serverC
         else if (serverConnector != null && serverConnector.getPort() > 0)
             builder.port(serverConnector.getPort());
 
-        log.info("Advertised URI: {}", builder.build());
+        URI uri = builder.build();
+        validateUriHost(uri);
+        log.info("Advertised URI: {}", uri);
 
-        return builder.build();
+        return uri;
+    }
+
+    /**
+     * Parses the uri and throws a more definitive error
+     * when the internal node to node communication can't happen due to an invalid host name.
+     */
+    private void validateUriHost(URI uri) {
+        if (uri.getHost() == null) {
+            String host = Utils.getHost(uri.getAuthority());

Review comment:
       Why use `Utils.getHost()` rather than `uri.getHost()`?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org