RFR: 5041655: (ch) FileLock: negative param and overflow issues

Alan Bateman alanb at openjdk.java.net
Fri Jan 28 05:55:15 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.

If the javadoc is changed to document long standing behavior then the change would need to be normative, I don't think an impl note works here.  I agree that throwing IAE is not an option. However, maybe you could try this:

1. Return false if size is negative, such a region can't overlap with with the region of any file lock.
2. If position is negative then treat it an overlap request on (0, size + position). That would mean an overlap on the positive range. This part may not require any code changes btw, the existing check might over it.

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

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


More information about the nio-dev mailing list