RFR: 5041655: (ch) FileLock: negative param and overflow issues
Alan Bateman
alanb at openjdk.java.net
Fri Jan 28 20:16:09 UTC 2022
On Thu, 27 Jan 2022 22:12:32 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Add an implementation note to `java.nio.channels.FileLock.overlaps(long,long)` indicating that the method does not check its parameters. Adding such checks would be an incompatible change.
> * I thought through several possibilities, including `size < 0` implies `false` and using `Math.addExact()` with `position` and `size`. If `Math.addExact(position, size)` throws then the exception would be ignored.
> * I don't understand what you intend here. Was it instead maybe `overlaps(position, size)` for `position < 0` becomes `overlaps(0, size)`?
It might be that checking if size <= 0 is enough. Maybe the starting point for this issue is a series of test cases with negative positions and sizes. All tests that uses a negative size should return false. The tests that use a negative position may overlap with the locked region.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7254
More information about the nio-dev
mailing list