浏览代码

Better Exception in NetworkUtilsTests (#42109)

* We are still running into an exception here every so often
   * Adjusted exception to contain interface name 
* Relates to #41549
Armin Braun 6 年之前
父节点
当前提交
ad2e9faa7e
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      server/src/test/java/org/elasticsearch/common/network/NetworkUtilsTests.java

+ 7 - 2
server/src/test/java/org/elasticsearch/common/network/NetworkUtilsTests.java

@@ -23,6 +23,7 @@ import org.elasticsearch.test.ESTestCase;
 
 import java.net.InetAddress;
 import java.net.NetworkInterface;
+import java.net.SocketException;
 import java.util.Collections;
 
 import static org.hamcrest.Matchers.containsString;
@@ -88,8 +89,12 @@ public class NetworkUtilsTests extends ESTestCase {
      */
     public void testAddressInterfaceLookup() throws Exception {
         for (NetworkInterface netIf : NetworkUtils.getInterfaces()) {
-            if (!netIf.isUp() || Collections.list(netIf.getInetAddresses()).isEmpty()) {
-                continue;
+            try {
+                if (!netIf.isUp() || Collections.list(netIf.getInetAddresses()).isEmpty()) {
+                    continue;
+                }
+            } catch (SocketException e) {
+                throw new AssertionError("Failed to check if interface [" + netIf + "] is up", e);
             }
 
             String name = netIf.getName();