mirror of
https://github.com/apache/rocketmq.git
synced 2026-08-31 02:20:15 +08:00
@@ -95,12 +95,12 @@ public class NetworkUtil {
|
||||
ArrayList<String> ipv4Result = new ArrayList<>();
|
||||
ArrayList<String> ipv6Result = new ArrayList<>();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
final NetworkInterface networkInterface = enumeration.nextElement();
|
||||
if (isBridge(networkInterface)) {
|
||||
final NetworkInterface nif = enumeration.nextElement();
|
||||
if (isBridge(nif) || nif.isVirtual() || nif.isPointToPoint() || !nif.isUp()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Enumeration<InetAddress> en = networkInterface.getInetAddresses();
|
||||
final Enumeration<InetAddress> en = nif.getInetAddresses();
|
||||
while (en.hasMoreElements()) {
|
||||
final InetAddress address = en.nextElement();
|
||||
if (!address.isLoopbackAddress()) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.apache.rocketmq.common;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import org.apache.rocketmq.common.utils.NetworkUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -23,10 +24,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class NetworkUtilTest {
|
||||
@Test
|
||||
public void testGetLocalAddress() throws Exception {
|
||||
public void testGetLocalAddress() {
|
||||
String localAddress = NetworkUtil.getLocalAddress();
|
||||
assertThat(localAddress).isNotNull();
|
||||
assertThat(localAddress.length()).isGreaterThan(0);
|
||||
assertThat(localAddress).isNotEqualTo(InetAddress.getLoopbackAddress().getHostAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user