RFR: 8310902: (fc) FileChannel.transferXXX async close and interrupt issues [v3]
Brian Burkhalter
bpb at openjdk.org
Wed Jun 28 16:45:57 UTC 2023
On Wed, 28 Jun 2023 06:18:35 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> This change fixes a number of bugs with FileChannel.transferTo/transerFrom that arise when the source or target channel is closed, or the thread is interrupted, during the transfer. More specifically:
>>
>> - The direct implementations operate on the raw file descriptor and don't prevent the target/source channel from being closed during the transfer. For this PR, the direct transferTo is limited to cases where the target is a FileChannel or SocketChannel. It could be extended to other SelChImpl implementations (SinkChannel, DatagramChannel) if needed, but they are less interesting at this time.
>>
>> - The transferTo/transferFrom methods are specified to throw ClosedByInterruptException after closing both channels. This is implemented inconsistently, and leaves one channel open in several cases.
>
> Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains seven additional commits since the last revision:
>
> - Merge
> - Make transferFromDirect more consistent
> - Merge
> - More robustness
> - Update
> - Update
> - Initial commit
test/jdk/java/nio/channels/FileChannel/CloseDuringTransfer.java line 194:
> 192: @ParameterizedTest
> 193: @MethodSource("sources")
> 194: void testInterruptTransferDuringTransferFrom(ReadableByteChannel src) throws Exception {
Should this be instead `testInterruptTransferDuringTransferFrom` for consistency with `testInterruptDuringTransferTo`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14656#discussion_r1245495216
More information about the nio-dev
mailing list