We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I try to lock regular file then locking it the second time will raise OverlappingFileLockException as described in FileChannel documentation
JimFS allows to lock the same file multiple times. Here is a test code
public void testJimfsLock() throws IOException { FileSystem jimFs = Jimfs.newFileSystem(); FileSystem fs = FileSystems.getDefault(); checkLock(jimFs.getPath("/lockfile")); checkLock(fs.getPath("/tmp/lockfile")); } private void checkLock(Path lockFilePath) throws IOException { System.out.println("lockFilePath=" + lockFilePath); FileChannel fileChannel = FileChannel.open(lockFilePath, StandardOpenOption.CREATE, StandardOpenOption.WRITE); FileLock lock1 = fileChannel.lock(); FileLock lock2 = null; try { lock2 = fileChannel.tryLock(); } catch (OverlappingFileLockException e) { System.out.println("got OverlappingFileLockException"); } System.out.println("lock1=" + lock1); System.out.println("lock2=" + lock2); }
It will print the following output:
lockFilePath=/lockfile lock1=com.google.common.jimfs.JimfsFileChannel$FakeFileLock[0:9223372036854775807 exclusive valid] lock2=com.google.common.jimfs.JimfsFileChannel$FakeFileLock[0:9223372036854775807 exclusive valid] lockFilePath=/tmp/lockfile got OverlappingFileLockException lock1=sun.nio.ch.FileLockImpl[0:9223372036854775807 exclusive valid] lock2=null
As you see attempting to lock file for the second time on regular file system leads to OverlappingFileLockException.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
If I try to lock regular file then locking it the second time will raise OverlappingFileLockException as described in FileChannel documentation
JimFS allows to lock the same file multiple times. Here is a test code
It will print the following output:
As you see attempting to lock file for the second time on regular file system leads to OverlappingFileLockException.
The text was updated successfully, but these errors were encountered: