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


##########
core/src/main/scala/kafka/network/SocketServer.scala:
##########
@@ -25,7 +25,7 @@ import java.util
 import java.util.Optional
 import java.util.concurrent._
 import java.util.concurrent.atomic._
-import kafka.cluster.{BrokerEndPoint, EndPoint}
+import kafka.cluster.{EndPoint}

Review Comment:
   We can remove the brackets since there is a single import.



##########
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:
   Hmm, an interesting thing is that if we take a ServerConnectionId with host 
name of [2001:db8::1] and call ServerConnectionId.fromString, we will get a 
slightly different ServerConnectionId since the hostname will not have the 
bracket. It's not an issue now, but it may cause confusion in the future. 



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