Make sure multicast tests pass on all os'es
This commit is contained in:
parent
d0f432b4d4
commit
4c0a5886ca
@ -28,6 +28,7 @@ import io.netty.channel.socket.DatagramChannelFactory;
|
||||
import io.netty.testsuite.util.TestUtils;
|
||||
import io.netty.util.internal.ExecutorUtil;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@ -72,7 +73,14 @@ public abstract class AbstractDatagramMulticastTest {
|
||||
|
||||
int port = TestUtils.getFreePort();
|
||||
|
||||
NetworkInterface iface = NetworkInterface.getNetworkInterfaces().nextElement();
|
||||
NetworkInterface iface = NetworkInterface.getByInetAddress(InetAddress.getLocalHost());
|
||||
|
||||
// check if the NetworkInterface is null, this is the case on my ubuntu dev machine but not on osx and windows.
|
||||
// if so fail back the the first interface
|
||||
if (iface == null) {
|
||||
// use nextElement() as NetWorkInterface.getByIndex(0) returns null
|
||||
iface = NetworkInterface.getNetworkInterfaces().nextElement();
|
||||
}
|
||||
sb.setOption("networkInterface", iface);
|
||||
sb.setOption("reuseAddress", true);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user