liudezhi2098 commented on a change in pull request #2240: fix the problem that the method InetAddress.getLocalHost().getHostAddress() gets ip as 127.0.0.1 URL: https://github.com/apache/bookkeeper/pull/2240#discussion_r365136851
########## File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/net/NetUtils.java ########## @@ -85,4 +85,52 @@ public static String resolveNetworkLocation(DNSToSwitchMapping dnsResolver, Inet return rNames.get(0); } + public static String getLocalHost() throws UnknownHostException { + try { + String ip = InetAddress.getLocalHost().getHostAddress(); + if (ip.equals("127.0.0.1")) { + return getAddress(); + } else + return ip; + } catch (Throwable e) { Review comment: This exception is superfluous and has been removed ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services