JDK-8199195 : (dc) DatagramChannel throws unspecified exceptions
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 11
  • Submitted: 2018-03-07
  • Updated: 2018-03-28
  • Resolved: 2018-03-21
Related Reports
CSR :  
Relates :  
Description
Summary
-------

The `java.nio.channels.DatagramChannel` methods `connect()` and `send()` throw unspecified exceptions.

Problem
-------

`DatagramChannel.send` may throw an unspecified `IllegalArgumentException` if the channel is already connected and its address parameter differs from the address to which the channel is connected. This exception should be changed to the more apt `java.nio.channels.AlreadyConnectedException`.

After the foregoing change, both `DatagramChannel.connect` and `DatagramChannel.send` may throw  `java.nio.channels.AlreadyConnectedException`, `java.nio.channels.UnresolvedAddressException`, or `java.nio.channels.UnsupportedAddressTypeException`, none of which are specified.

Solution
--------

Update the `DatagramChannel.connect` and `DatagramChannel.send` documentation to specify that these methods may throw `java.nio.channels.AlreadyConnectedException`, `java.nio.channels.UnresolvedAddressException`, and `java.nio.channels.UnsupportedAddressTypeException`.

Specification
-------------

Please refer to the attached specdiff `specdiff-dc-exceptions-8198753.zip`.
Comments
Added release note JDK-8200089 as requested.
22-03-2018

Out of an abundance of caution for changing some long-standing behavior, please create a release note item for this change. Moving to Approved conditional on the release note.
21-03-2018

It is worth to specify -- "UnsupportedAddressTypeException - If the type of the given address is not supported" for the method public abstract DatagramChannel connect���(SocketAddress remote) throws IOException In DatagramChannel.
16-03-2018