smengcl commented on code in PR #10933:
URL: https://github.com/apache/ozone/pull/10933#discussion_r3756358712


##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java:
##########
@@ -158,21 +159,20 @@ public void initialize(URI name, Configuration conf) 
throws IOException {
       throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
     }
 
-    String omHostOrServiceId;
-    int omPort = -1;
-    // Parse hostname and port
-    String[] parts = authority.split(":");
-    if (parts.length > 2) {
+    // Parse hostname and port. HostAndPort is bracket-aware, so IPv6 literal
+    // authorities (for example [::1]:9862) are split correctly instead of on
+    // every colon.
+    final HostAndPort hostAndPort;
+    try {
+      hostAndPort = HostAndPort.fromString(authority);
+    } catch (IllegalArgumentException e) {
       throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
     }
-    omHostOrServiceId = parts[0];
-    if (parts.length == 2) {
-      try {
-        omPort = Integer.parseInt(parts[1]);
-      } catch (NumberFormatException e) {
-        throw new IllegalArgumentException(URI_EXCEPTION_TEXT);
-      }
-    }
+    int omPort = hostAndPort.hasPort() ? hostAndPort.getPort() : -1;
+    String host = hostAndPort.getHost();
+    // Keep IPv6 literals bracketed so the downstream host:port assembly that
+    // builds the OM address stays unambiguous.
+    String omHostOrServiceId = host.contains(":") ? "[" + host + "]" : host;

Review Comment:
   Now that OzoneClientFactory.getRpcClient and OmUtils.resolveOmHost use 
getHostPortString, this value no longer needs brackets. Please pass host 
directly to createAdapter and update the test expectations to bare literals 
(::1 and 2001:db8::1). The filesystem URI remains bracketed because it is 
rebuilt from authority.



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