RFR: 8319417: (dc) DatagramChannel.connect undocumented behavior [v2]

Mark Sheppard msheppar at openjdk.org
Tue Nov 28 18:53:06 UTC 2023


On Tue, 28 Nov 2023 13:48:35 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> > Also, the return for the case of an unbound DatagramSocket or DatagramChannel is not specified.
> 
> DatagramChannel::getLocalAddress is specified to return null when channel's socket is not bound. DatagramSocket::getLocalSocketAddress also specifies that it returns null when not bound. But maybe you mean something else?

Yes, indeed I did mean something else, I seemed to have lost the tail end of my sentence (the punchline, so to say)
It should have read something like:

Also, the return for the case of an unbound DatagramSocket or DatagramChannel is not specified consistently, and provide conflicting return specifications.

DatagramChannel return spec

Returns:
    The SocketAddress that the socket is bound to, or the SocketAddress representing the loopback address if denied by the security manager, or null if the channel's socket is not bound.

DatagramSocket return spec

Returns:
    the local address to which the socket is bound, null if the socket is closed, or an InetAddress representing [wildcard](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/InetAddress.html#isAnyLocalAddress()) address if either the socket is not bound, or the security manager checkConnect method does not allow the operation

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16635#issuecomment-1830479494


More information about the nio-dev mailing list