JDK-6964714 : NetworkInterface getInetAddresses enumerates IPv6 addresses if java.net.preferIPvStack property set
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-06-28
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b105Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
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());
                }
            }
        
    }
}

Comments
EVALUATION Changeset: 25050030a320 Author: dsamersoff Date: 2010-07-13 15:32 +0400 URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/25050030a320 6964714: NetworkInterface getInetAddresses enumerates IPv6 addresses if java.net.preferIPvStack property set Summary: User can disable ipv6 explicitly, have to check it Reviewed-by: chegar, alanb ! src/solaris/native/java/net/NetworkInterface.c + test/java/net/NetworkInterface/IPv4Only.java
13-07-2010

EVALUATION Missed call to ipv6_available()
01-07-2010