RFR: 8140241: (fc) Data transfer from FileChannel to itself causes hang in case of overlap [v4]
Alan Bateman
alanb at openjdk.java.net
Wed Aug 11 18:57:24 UTC 2021
On Wed, 11 Aug 2021 15:49:55 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> This request proposes to fix a failure on macOS which occurs when transferring to or from a file channel from or to the same file channel when the source and destination intervals overlap.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8140241: Restructure test to use try-with-resources for file closing
Marked as reviewed by alanb (Reviewer).
src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java line 591:
> 589: synchronized (positionLock) {
> 590: long posThis = position();
> 591: if (posThis - count + 1 <= position &&
I realise I suggested we need the positionLock here but I don't think it is needed now because there is only one call to position().
src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java line 803:
> 801:
> 802: if (src instanceof FileChannelImpl) {
> 803: long n = transferFromFileChannel((FileChannelImpl)src, position, count);
It might be a bit cleaner to use the pattern matching with the instanceof to avoid the cast to FileChannelImpl.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5061
More information about the nio-dev
mailing list