RFR: 5041655: (ch) FileLock: negative param and overflow issues [v10]
Brian Burkhalter
bpb at openjdk.java.net
Thu Feb 17 16:53:05 UTC 2022
On Thu, 17 Feb 2022 13:23:37 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 5041655: Fix problem exposed by modified lock tests
>
> src/java.base/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java line 184:
>
>> 182: throw new NonWritableChannelException();
>> 183:
>> 184: long len = size != 0 ? size : Long.MAX_VALUE - Math.max(0, position);
>
> In other places, the changes just checks if size is 0 and set it to Long.MAX_VALUE - Math.max(0, position). This avoids having both "len" and "size" and avoids potential mistakes. Can we do the same here and in the Windows implementation?
In both cases the `size` parameter is final and cannot be reassigned, so either the parameter has to be made non-final or a new variable has to be used.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7254
More information about the nio-dev
mailing list