Fix network interface test issues . (#2774)

pull/2811/head
o‘Laoxu 2 years ago committed by GitHub
parent 11d6cf90bf
commit 3ba918ce09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,7 @@ package com.alibaba.cloud.nacos.registry;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
@ -119,7 +120,8 @@ public class NacosAutoServiceRegistrationIpNetworkInterfaceTests {
while (inetAddress.hasMoreElements()) {
InetAddress currentAddress = inetAddress.nextElement();
if (currentAddress instanceof Inet4Address
&& !currentAddress.isLoopbackAddress()) {
|| currentAddress instanceof Inet6Address
&& !currentAddress.isLoopbackAddress()) {
return currentAddress.getHostAddress();
}
}
@ -152,7 +154,8 @@ public class NacosAutoServiceRegistrationIpNetworkInterfaceTests {
while (inetAddress.hasMoreElements()) {
InetAddress currentAddress = inetAddress.nextElement();
if (currentAddress instanceof Inet4Address
&& !currentAddress.isLoopbackAddress()) {
|| currentAddress instanceof Inet6Address
&& !currentAddress.isLoopbackAddress()) {
hasValidNetworkInterface = true;
netWorkInterfaceName = networkInterface.getName();
System.setProperty(

Loading…
Cancel
Save