Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8231260 (dc) DatagramChannel::disconnect changes the port of the local address to 0 (lnx)
  3. JDK-8231881

Release Note: DatagramChannel.disconnect Might Leave the Channel's Socket in an Unspecified State

XMLWordPrintable

    • Verified

       The `DatagramChannel` implementation has been updated in this release so that the `disconnect` method attempts to workaround Linux kernel behavior that reverts the local port to 0 after dissolving the association. The issue arises when a `DatagramChannel` is initially bound to an ephemeral port, connected (by calling its `connect` method), and then disconnected (by calling its `disconnect` method). The workaround in the `DatagramChannel::disconnect` is to attempt to re-bind the channel's socket to its original port. This usually succeeds, but if it fails, an `IOException` is thrown. This workaround has been used in the `DatagramSocket` implementation for several releases.

      As part of this change, the `javadoc` for `DatagramChannel::disconnect` has been updated with an API note to make it clear that an `IOException` might leave the channel's socket in an unspecified state. The API note also strongly recommends that the channel be closed when the `disconnect` fails.

            dfuchs Daniel Fuchs
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: