RFR[8246707]: '(sc) SocketChannel.read/write throws AsynchronousCloseException on closed channel'

Conor Cleary conor.cleary at oracle.com
Fri Aug 7 16:14:32 UTC 2020


Hi Alan,

Your point about assertThrows was correct, it did not fail when a 
sub-class of CCE was thrown i.e AsynchronousCloseException. It has 
therefore been replaced by catching the exception in as a Throwable and 
comparing it with the desired exception using assertEquals. The correct 
test behavior was verified by running the tests both with and without 
the changes to SocketChannelImpl.

Other minor changes were made as per your feedback related to 
SocketChannelImpl.

  * webrev:
    http://cr.openjdk.java.net/~ccleary/issues/webrevs-store/8246707/webrevs/webrev.06/
  * bug: https://bugs.openjdk.java.net/browse/JDK-8246707

-Conor

On 31/07/2020 18:26, Alan Bateman wrote:
> On 31/07/2020 16:16, Conor Cleary wrote:
>>
>> Hi guys,
>>
>> If you have a minute could you take a look at my new webrev for 
>> JDK-8246707 '(sc) SocketChannel.read/write throws 
>> AsynchronousCloseException on closed channel'?
>>
>> I updated the revision to include ensureOpenAndConnected() checks for 
>> blockingRead, blockingWriteFully and sendOutOfBandData before 
>> checking the blocking mode. Also, a test to check that a 
>> ClosedChannelException is thrown for read and write operations on a 
>> closed SocketChannel is now included (ReadWriteAfterClose.java).
>>
>> Thanks!
>>
>> bug: https://bugs.openjdk.java.net/browse/JDK-8246707
>> webrev: 
>> http://cr.openjdk.java.net/~ccleary/issues/webrevs-store/8246707/webrevs/webrev.05/
>>
> Does the test fail without the changes? I'm asking because I assume 
> TestNG assertThrows(CCE, ...) will not fail when a sub-class of CCE is 
> thrown.
>
> The changes to SocketChannelImpl look correct. One other thing is the 
> beginWrite at L1264 should be in try-finally block, not before. Minor 
> nit the comment at L1178 is for the isBlocking check, meaning 
> ensureOpenAndConnected should be before comment rather than after. I'd 
> prefer if there was an empty line after the ensureOpenAndConnect in 
> both blockingRead and blockingWriteFully to keep the style consistent.
>
> -Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20200807/a74891c3/attachment.htm>


More information about the nio-dev mailing list