JDK-7132924 : (dc) DatagramChannel.disconnect throws SocketException with IPv4 socket and IPv6 enabled [macosx]
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 7,7u4,7u6,7u21
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: generic,x86
  • Submitted: 2012-01-24
  • Updated: 2013-06-26
  • Resolved: 2012-05-14
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 8
8 b38Fixed
Related Reports
Duplicate :  
Description
nioDatagramChannel/DatagramChannelTest03 
nioDatagramChannel/DatagramChannelTest05 

SQE tests failed on MacOs. After calling disconnect() method an exception throws:

java.net.SocketException: Invalid argument
at sun.nio.ch.DatagramChannelImpl.disconnect0(Native Method)
at sun.nio.ch.DatagramChannelImpl.disconnect(DatagramChannelImpl.java:740)
at TestServer.go(DatagramChannelTest03.java:164)
at TestThread.run(DatagramChannelTest03.java:240)
java.net.SocketException: Invalid argument
at sun.nio.ch.DatagramChannelImpl.disconnect0(Native Method)
at sun.nio.ch.DatagramChannelImpl.disconnect(DatagramChannelImpl.java:740)
at TestClient.go(DatagramChannelTest03.java:217)
at TestThread.run(DatagramChannelTest03.java:240)


 
A simple test case is attached to reflect this problem.

Comments
There is the same issue on MacOS with 7u21b06.
20-03-2013

EVALUATION The test creates the DatagamChannel with open(StandardProtocolFamily.INET) and so it creating a DatagramChannel to an IPv4 socket when IPv6 is available. The disconnect implementation on BSD/Mac can't handle this as it's not passed the protocol family. In order to fix this we need to pass in the protocol family so that disconnect0 can do the right thing. As this requires changing the code for all platforms then it would be risky to be in 7u4. It's also highly unlikely that anyone will run into this because open(ProtocolFamily) is really only intended for applications that are doing multicasting.
07-02-2012