RFR: 8231260: (dc) DatagramChannel::disconnect changes the port of the local address to 0 (lnx)
Daniel Fuchs
daniel.fuchs at oracle.com
Tue Oct 8 14:40:38 UTC 2019
On 08/10/2019 15:29, Alan Bateman wrote:
> On 08/10/2019 15:20, mark sheppard wrote:
>> :
>>
>> Q: is localAddress.getPort() == 0 indicative that the
>> DatagramChannel is unbound ?
>>
> getLocalAddress() returns a SocketAddress when bound, it returns null
> when not bound. I don't think we should get too hung up on corner case
> that arises when the local port cannot be restored (by re-binding). The
> javadoc sets the expectations that the channel's socket is in an
> undefined state when disconnect fails.
+1 : you would be in uncharted territory and that's exactly why
we want to throw an exception when rebind fails and why we recommend
closing the channel when that happens.
-- daniel
>
> -Alan.
More information about the nio-dev
mailing list