chia7712 commented on code in PR #17519:
URL: https://github.com/apache/kafka/pull/17519#discussion_r1806888599


##########
clients/src/test/java/org/apache/kafka/common/network/ServerConnectionIdTest.java:
##########
@@ -110,4 +110,38 @@ public void testGenerateConnectionId() throws IOException {
         assertEquals("127.0.0.1:9092-127.0.0.1:9093-0-0", 
ServerConnectionId.generateConnectionId(socket, 0, 0));
         assertEquals("127.0.0.1:9092-127.0.0.1:9093-1-2", 
ServerConnectionId.generateConnectionId(socket, 1, 2));
     }
+
+    @Test
+    public void testParseHostPort() {
+        Optional<BrokerEndPoint> brokerEndPoint = 
ServerConnectionId.parseHostPort("myhost:9092");
+        assertTrue(brokerEndPoint.isPresent());
+        assertEquals("myhost", brokerEndPoint.get().host());
+        assertEquals(9092, brokerEndPoint.get().port());
+
+        brokerEndPoint = ServerConnectionId.parseHostPort("127.0.0.1:9092");
+        assertTrue(brokerEndPoint.isPresent());
+        assertEquals("127.0.0.1", brokerEndPoint.get().host());
+        assertEquals(9092, brokerEndPoint.get().port());
+
+        // IPv6 endpoint
+        brokerEndPoint = 
ServerConnectionId.parseHostPort("[2001:db8::1]:9092");

Review Comment:
   `ServerConnectionId` doesn't face ambiguity like a URL does, so in my 
opinion, the hostname in `ServerConnectionId` doesn't need brackets.



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