JDK-8004232 : (dc) DatagramChannel.bind(null) throws UnsupportedAddressTypeException if IPv4 socket and java.net.preferIPv6Addresses set to true
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2012-11-30
  • Updated: 2013-02-26
  • Resolved: 2013-02-26
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
7u6Resolved
Related Reports
Duplicate :  
Duplicate :  
Description
This issue causes (at least) 2 JCK test failures:

api/java_nio/channels/DatagramChannel/DatagramChannel.html#NetworkChannel[bindToAutoAddress_test]
api/java_nio/channels/DatagramChannel/DatagramChannel.html#NetworkChannel[bindRepeatedly_test]

The rest is copied from exclude request JCK-7300127:

--- start of quote ----

 In JavaSE7 (jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java)
     public DatagramChannel bind(SocketAddress local) throws IOException {
           .....
                    InetSocketAddress isa;
                    if (local == null) {
                        isa = new InetSocketAddress(0); <= this will create IPv6 socket
                    } else {
                        isa = Net.checkAddress(local);

                        // only Inet4Address allowed with IPv4 socket
                        if (family == StandardProtocolFamily.INET) {
                            InetAddress addr = isa.getAddress();
                            if (!(addr instanceof Inet4Address))
                                throw new UnsupportedAddressTypeException();
                        }
                    }
                    SecurityManager sm = System.getSecurityManager();
                    if (sm != null) {
                        sm.checkListen(isa.getPort());
                    }
                    Net.bind(family, fd, isa.getAddress(), isa.getPort()); <= family is INET(IPv4)
                    localAddress = Net.localAddress(fd);
                }
            }

So they execute in IPv4 mode (family=INET) *AND* java.net.preferIPv6Addresses is TRUE,
then InetSoketAddress(0) constructor creates IPv6 address.
Later it tries to bind with IPv6 address on IPv4 mode.

---- end of quote ----
Comments
Dup of 7161881
26-02-2013