JDK-8198753 : (dc) DatagramChannel throws unspecified exceptions
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 11
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-02-27
  • Updated: 2018-06-27
  • Resolved: 2018-03-22
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 11
11 b07Fixed
Related Reports
CSR :  
Sub Tasks
JDK-8200089 :  
Description
The connect method does not specify the exception to be thrown when the datagram channel is already connected. It has historically thrown IllegalStateException. In JDK 11 it throws the more specific AlreadyConnectedException (which seems the best choice to specify).

Another issue with connect is that it doesn't specify UnsupportedAddressTypeException and UnresolvedAddressException. We need to get this consistent with SocketChannel.connect.

Invoking the send on a datagram channel that is connected is likely a user error. The implementation has historically allowed this method to be used when send to the address that the channel is connected (as this case is benign). It has thrown IllegalArgumentException if the datagram channel is connected to a different target address. Neither case was specified. We should keep existing behavior when sending to the address that the channel is connected too. AlreadyConnectedException may be a better exception for the case that the channel is connected and the user is attempting to send to a different address.