Uses List instead of Enumeration.

This commit is contained in:
boris 2014-09-03 14:34:12 +00:00
parent 04e0befbef
commit 58b40d184f

View File

@ -112,7 +112,7 @@ public class MultiplexingTcpHostHarvester
public MultiplexingTcpHostHarvester(int port) public MultiplexingTcpHostHarvester(int port)
throws IOException throws IOException
{ {
this(port, NetworkInterface.getNetworkInterfaces()); this(port, Collections.list(NetworkInterface.getNetworkInterfaces()));
} }
/** /**
@ -138,7 +138,7 @@ public class MultiplexingTcpHostHarvester
* @param interfaces the interfaces to listen on. * @param interfaces the interfaces to listen on.
*/ */
public MultiplexingTcpHostHarvester(int port, public MultiplexingTcpHostHarvester(int port,
Enumeration<NetworkInterface> interfaces) List<NetworkInterface> interfaces)
throws IOException throws IOException
{ {
initializeLocalAddresses(port, interfaces); initializeLocalAddresses(port, interfaces);
@ -179,16 +179,16 @@ public class MultiplexingTcpHostHarvester
*/ */
private void initializeLocalAddresses( private void initializeLocalAddresses(
int port, int port,
Enumeration<NetworkInterface> interfaces) List<NetworkInterface> interfaces)
throws IOException throws IOException
{ {
boolean useIPv6 = !StackProperties.getBoolean( boolean useIPv6 = !StackProperties.getBoolean(
StackProperties.DISABLE_IPv6, StackProperties.DISABLE_IPv6,
false); false);
while (interfaces.hasMoreElements()) for (NetworkInterface iface : interfaces)
{ {
NetworkInterface iface = interfaces.nextElement();
if (NetworkUtils.isInterfaceLoopback(iface) if (NetworkUtils.isInterfaceLoopback(iface)
|| !NetworkUtils.isInterfaceUp(iface) || !NetworkUtils.isInterfaceUp(iface)
|| !HostCandidateHarvester.isInterfaceAllowed(iface)) || !HostCandidateHarvester.isInterfaceAllowed(iface))