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 may leave the channel's socket in an unspecified state


    • Type: Sub-task
    • Status: Resolved
    • Priority: P4
    • Resolution: Delivered
    • Affects Version/s: 14
    • Fix Version/s: 14
    • Component/s: core-libs


       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 will usually succeed but if it fails then `IOException` will be 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` may leave the channel's socket in an unspecified state. The API note also strongly recommends that the channel be closed when `disconnect` fails.




            • Assignee:
              dfuchs Daniel Fuchs
              dfuchs Daniel Fuchs
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: