On my Ubuntu box, the hosts file contains: $ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 PC-L00XX And InetAddress.getLocalHost() returns 127.0.1.1, so the test isLocal_returns_true_on_localhost_address_or_host was failingtags/10.5.0.89998
@@ -124,7 +124,11 @@ public class NetworkUtilsImpl implements NetworkUtils { | |||
try { | |||
Optional<InetAddress> inetAddress = toInetAddress(hostOrAddress); | |||
if (inetAddress.isPresent()) { | |||
return NetworkInterface.getByInetAddress(inetAddress.get()) != null; | |||
var addr = inetAddress.get(); | |||
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) { | |||
return true; | |||
} | |||
return NetworkInterface.getByInetAddress(addr) != null; | |||
} | |||
return false; | |||
} catch (SocketException e) { |