private synchronized void addLock(FileLock lock) throws OverlappingFileLockException {
  long lockEnd=lock.position() + lock.size();
  for (  FileLock existingLock : locks) {
    if (existingLock.position() > lockEnd) {
      break;
    }
    if (existingLock.overlaps(lock.position(),lock.size())) {
      throw new OverlappingFileLockException();
    }
  }
  locks.add(lock);
}

private synchronized void addLock ( FileLock lock ) throws OverlappingFileLockException { long lockEnd = lock . position ( ) + lock . size ( ) ; for ( FileLock existingLock : locks ) { if ( existingLock . position ( ) > lockEnd ) { break ; } if ( existingLock . overlaps ( lock . position ( ) , lock . size ( ) ) ) { throw new OverlappingFileLockException ( ) ; } } locks . add ( lock ) ; }
add a new pending lock to the manager . throws an exception if the lock would overlap an existing lock . once the lock is acquired it remains in this set as an acquired lock .
