@Test public void differentDirectoriesDoNotContend() throws Exception { Path directory1 = temporaryFolder.newFolder().toPath(); Path directory2 = temporaryFolder.newFolder().toPath(); LocalLockManager lockManager = new LocalLockManager(); try (CloseLock lock1 = lockManager.lockOrFail(directory1)) { try (CloseLock lock2 = lockManager.lockOrFail(directory2)) { assertNotNull(lock1); assertNotNull(lock2); } } }
public CloseLock lockOrFail(Path path) throws IOException { if (LOCKS.add(path)) { return new LocalLock(path); } throw new IOException("Local lock already held: " + path); }
LocalLockManager implements LockManager { public CloseLock lockOrFail(Path path) throws IOException { if (LOCKS.add(path)) { return new LocalLock(path); } throw new IOException("Local lock already held: " + path); } }
LocalLockManager implements LockManager { public CloseLock lockOrFail(Path path) throws IOException { if (LOCKS.add(path)) { return new LocalLock(path); } throw new IOException("Local lock already held: " + path); }  }
LocalLockManager implements LockManager { public CloseLock lockOrFail(Path path) throws IOException { if (LOCKS.add(path)) { return new LocalLock(path); } throw new IOException("Local lock already held: " + path); }  CloseLock lockOrFail(Path path); }
LocalLockManager implements LockManager { public CloseLock lockOrFail(Path path) throws IOException { if (LOCKS.add(path)) { return new LocalLock(path); } throw new IOException("Local lock already held: " + path); }  CloseLock lockOrFail(Path path);  }