apoorvmittal10 commented on code in PR #17519:
URL: https://github.com/apache/kafka/pull/17519#discussion_r1807759687
##########
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:
Do I need to dix anything in this? I have just used the exisiting regex for
parsing, from scala to java.
--
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]