8232673: (dc) DatagramChannel socket adaptor issues

Alan Bateman Alan.Bateman at oracle.com
Tue Oct 29 15:38:30 UTC 2019



On 29/10/2019 15:18, Daniel Fuchs wrote:
> Hi Alan,
>
> Thanks for this patch that fixes and brings into the mainline
> many of the small issues we noticed while working on JDK-8230211.
>
> I looked at the patch and I think it is good.
>
> A couple of comments still:
>
> DatagramChannelImpl:
>
>  452                     assert sender != null;
>
> pedantically that should be:
>
>                          assert sender != null || !isOpen();
The only place where it is safe to assert on the channel open/close 
state is implCloseSelectableChannel. The reason is that the channel can 
be (asynchronously) closed at any time and this sets the closed state 
before it coordinates the close with any threads that are doing I/O.


> :
>
> I also believe a similar-ish (but maybe more relevant) kind of
> issue would arise for:
>
>  491                 assert n >= 0;
>
> at this point - and as per line
>
>  484                     while (IOStatus.okayToRetry(n) && isOpen()) {
>
> then n could well be < 0 if the channel is closed.
> I suspect the assertion at line 491 should therefore be preceded
> with:
>
>    if (n < 0) return n;
>
> either after line 487 or after line 490.
I will re-examine the asserts (I agree they are hard to be confident 
that they are valid).

-Alan


More information about the nio-dev mailing list