Code Review Request: 7060243: (dc) Multicasting tests fail on Windows XP if IPv6 is enabled
Kurchi Hazra
kurchi.subhra.hazra at oracle.com
Fri Aug 26 13:06:30 PDT 2011
Hi,
java/nio/channels/DatagramChannel/BasicMulticastTests.java and java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java were throwing an UnSupportedOperationException on Windows XP 32 bit,
with an IPV6 stack, since NIO Channels do not support the old stack. Both these testcases rely on the InetAddresses returned by probe() in test/java/nio/channels/DatagramChannel/NetworkConfiguration.java.
Hence, the fix was to modify probe() in NetworkConfiguration.java to not return the list of IPV6 InetAddresses if the OS is Windows and the version is lower than 6.
Submitting hg diff since I do not have an openjdk account:
diff --git a/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java b/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
--- a/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
+++ b/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
@@ -27,6 +27,7 @@ import java.io.IOException;
/**
* Helper class for multicasting tests.
+ * @bug 7060243
*/
class NetworkConfiguration {
@@ -62,7 +63,7 @@ class NetworkConfiguration {
new HashMap<NetworkInterface,List<InetAddress>>();
Map<NetworkInterface,List<InetAddress>> ip6Interfaces =
new HashMap<NetworkInterface,List<InetAddress>>();
-
+ boolean ipv6Supported= isIpv6Supported();
// find the interfaces that support IPv4 and IPv6
List<NetworkInterface> nifs = Collections
.list(NetworkInterface.getNetworkInterfaces());
@@ -70,7 +71,6 @@ class NetworkConfiguration {
// ignore intertaces that are down or don't support multicast
if (!nif.isUp() || !nif.supportsMulticast() || nif.isLoopback())
continue;
-
List<InetAddress> addrs = Collections.list(nif.getInetAddresses());
for (InetAddress addr: addrs) {
if (!addr.isAnyLocalAddress()) {
@@ -81,7 +81,7 @@ class NetworkConfiguration {
}
list.add(addr);
ip4Interfaces.put(nif, list);
- } else if (addr instanceof Inet6Address) {
+ } else if ( ipv6Supported&& (addr instanceof Inet6Address)) {
List<InetAddress> list = ip6Interfaces.get(nif);
if (list == null) {
list = new LinkedList<InetAddress>();
@@ -94,4 +94,16 @@ class NetworkConfiguration {
}
return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
}
+
+ private static boolean isIpv6Supported()
+ {
+ boolean returnVal=true;
+
+ /*IPV6 is not supported for Windows XP/Server 2003*/
+ if((System.getProperty("os.name").contains("Windows"))&& (Float.valueOf(System.getProperty("os.version"))<6)) {
+ returnVal=false;
+ }
+
+ return returnVal;
+ }
}
Thanks,
--
-Kurchi
More information about the nio-dev
mailing list