You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2020/03/26 11:25:32 UTC

[GitHub] [bookkeeper] 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

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_r398498456
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/net/NetUtils.java
 ##########
 @@ -85,4 +92,46 @@ public static String resolveNetworkLocation(DNSToSwitchMapping dnsResolver, Inet
         return rNames.get(0);
     }
 
+    public static String getLocalHost() throws UnknownHostException {
+        String ip = InetAddress.getLocalHost().getHostAddress();
+        if (InetAddress.getLocalHost().isLoopbackAddress()) {
+            return getAddress();
+        } else {
+            return ip;
+        }
+
+    }
+
+    private static boolean isboolIp(String ipAddress) {
 
 Review comment:
   I will call this method isIpAddressValid 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services