Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8235783

DatagramSocket::connect and DatagramSocket::disconnect should allow an implementation to throw UncheckedIOException

XMLWordPrintable

    • b08

      DatagramChannel::disconnect throws IOException while DatagramSocket::disconnect does not. As a result, the DatagramChannel::socket adaptor which calls DatagramChannel::disconnect currently catches IOException and rethrows it as Error.

      On the other hand, DatagramChannel::disconnect has been fixed to rebind the socket in those cases where the underlying platform `disconnect` changes the local socket address. This unfortunately introduce the possibility that `disconnect` will fail. DatagramChannel::disconnect may throw an IOException in that case and its API documentation has been updated to recommend closing the socket if that happens. See JDK-8231260 and JDK-8231259.

      This means that the risk of the DatagramChannel::socket adapter throwing an Error has slightly increased. This is a bit hostile to clients of this API.

      The proposal is to change the DatagramChannel::socket adapter to throw UncheckedIOException instead, and update the specification of DatagramSocket::disconnect to document that an implementation may throw UncheckedIOException, and to recommend closing the socket in that case, in much the same way that was done for DatagramChannel.

            pconcannon Patrick Concannon (Inactive)
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: