adoroszlai commented on code in PR #10686:
URL: https://github.com/apache/ozone/pull/10686#discussion_r3552708290


##########
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/TestHddsUtils.java:
##########
@@ -59,6 +59,23 @@ void testGetHostName() {
         HddsUtils.getHostName(":1234"));
   }
 
+  @Test
+  void testGetHostPortString() {
+    // Hostnames and IPv4 literals are joined with a plain colon.
+    assertEquals("host1:9858", HddsUtils.getHostPortString("host1", 9858));
+    assertEquals("1.2.3.4:9858", HddsUtils.getHostPortString("1.2.3.4", 9858));
+
+    // Bare IPv6 literals must be bracketed so the result is an unambiguous
+    // Ratis/gRPC target.
+    assertEquals("[2001:db8::1]:9858",
+        HddsUtils.getHostPortString("2001:db8::1", 9858));
+    assertEquals("[::1]:9858", HddsUtils.getHostPortString("::1", 9858));
+
+    // Already-bracketed IPv6 literals keep a single pair of brackets.
+    assertEquals("[2001:db8::1]:9858",
+        HddsUtils.getHostPortString("[2001:db8::1]", 9858));

Review Comment:
   nit: please don't wrap at 80 chars



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to