File locking supported on all platforms?
Alan Bateman
Alan.Bateman at oracle.com
Tue Jul 14 10:53:11 UTC 2020
On 14/07/2020 10:59, Jonas Konrad wrote:
>> I see NFS is mentioned in the discussion. Yes, there can be issues in
>> NFS environments but if the lock daemon is not running on the remote
>> NFS server then I would expect the lock or tryLock methods to throw
>> an IOException "No locks available".
>
> Nope, it'll just grant the lock twice. Linux fcntl will not return an
> error so I don't see how the JDK could detect this case anyway
Do you have an example to explain what you mean? The lock and tryLock
methods should throw OverlappingFileLockException if you attempt to lock
a region that overlaps with a region already held in same VM. So you
shouldn't see a second call to fnctl.
-Alan
More information about the nio-dev
mailing list