RFR: 8140241: (fc) Data transfer from FileChannel to itself causes hang in case of overlap [v4]

Brian Burkhalter bpb at openjdk.java.net
Wed Aug 11 19:26:28 UTC 2021


On Wed, 11 Aug 2021 18:53:53 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> 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
>
> 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().

Will remove.

> 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.

Right, I should have caught that myself.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5061


More information about the nio-dev mailing list