smengcl commented on code in PR #8964:
URL: https://github.com/apache/hadoop/pull/8964#discussion_r4544435676


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java:
##########
@@ -326,22 +326,17 @@ public static String 
getResolvedRemoteRMWebAppURLWithoutScheme(
 
   public static String getResolvedAddress(InetSocketAddress address) {
     address = NetUtils.getConnectAddress(address);
-    StringBuilder sb = new StringBuilder();
+    String host = address.getHostName();
     InetAddress resolved = address.getAddress();
     if (resolved == null || resolved.isAnyLocalAddress() ||
         resolved.isLoopbackAddress()) {
-      String lh = address.getHostName();
       try {
-        lh = InetAddress.getLocalHost().getCanonicalHostName();
+        host = InetAddress.getLocalHost().getCanonicalHostName();
       } catch (UnknownHostException e) {
         //Ignore and fallback.
       }
-      sb.append(lh);
-    } else {
-      sb.append(address.getHostName());
     }
-    sb.append(":").append(address.getPort());
-    return sb.toString();
+    return NetUtils.getHostPortString(host, address.getPort());

Review Comment:
   Agreed, that split was already wrong before this change (`2001:db8::1:8088` 
became `2001`). Filed YARN-12061 to fix it, along with the same `split(":")` 
pattern in `ResourceManager`, `WebAppProxy` and `Router`.



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