File locking supported on all platforms?

Jonas Konrad me at yawk.at
Tue Jul 14 10:56:19 UTC 2020


Sorry I meant when locking the same file from two processes. When the 
file is on an nfs without lock daemon and two processes on different 
machines try to lock it at the same time both will succeed without 
error. There is no "No locks available" error.

- Jonas

On 7/14/20 12:53 PM, Alan Bateman wrote:
> 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