Skip to content

Commit ad2e9fa

Browse files
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
1 parent 4586f29 commit ad2e9fa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

server/src/test/java/org/elasticsearch/common/network/NetworkUtilsTests.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import java.net.InetAddress;
2525
import java.net.NetworkInterface;
26+
import java.net.SocketException;
2627
import java.util.Collections;
2728

2829
import static org.hamcrest.Matchers.containsString;
@@ -88,8 +89,12 @@ public void testFilter() throws Exception {
8889
*/
8990
public void testAddressInterfaceLookup() throws Exception {
9091
for (NetworkInterface netIf : NetworkUtils.getInterfaces()) {
91-
if (!netIf.isUp() || Collections.list(netIf.getInetAddresses()).isEmpty()) {
92-
continue;
92+
try {
93+
if (!netIf.isUp() || Collections.list(netIf.getInetAddresses()).isEmpty()) {
94+
continue;
95+
}
96+
} catch (SocketException e) {
97+
throw new AssertionError("Failed to check if interface [" + netIf + "] is up", e);
9398
}
9499

95100
String name = netIf.getName();

0 commit comments

Comments
 (0)