|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
We appear to have a regression in jdk7/tl/jdk since this push:
http://hg.openjdk.java.net/jdk7/tl/jdk/rev/887e525597f8
The problem is that NetworkInterface.getInetAddresses enumerates IPv6 addresses when java.net.preferIPv4Stack=true.
Try the following with jdk7-b98 and compare with a build of jdk7/tl/jdk. The latter enumerates IPv6 addresses, a nasty regression.
import java.net.*;
import java.util.*;
public class Test {
public static void main(String[] args) throws Exception {
Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
while (nifs.hasMoreElements()) {
NetworkInterface nif = nifs.nextElement();
Enumeration<InetAddress> addrs = nif.getInetAddresses();
while (addrs.hasMoreElements()) {
System.out.println(addrs.nextElement().getHostAddress());
}
}
}
}
|