eolivelli 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_r369246969
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/net/NetUtils.java
##########
@@ -85,4 +86,44 @@ public static String
resolveNetworkLocation(DNSToSwitchMapping dnsResolver, Inet
return rNames.get(0);
}
+ public static String getLocalHost() throws UnknownHostException {
+ String ip = InetAddress.getLocalHost().getHostAddress();
+ if (ip.equals("127.0.0.1")) {
Review comment:
We should use a better way, this approach does not deal with the whole
127.0.0.0/24 class and with ipv6
I think there is some InteAddress.isLoopback method
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services