question: 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 ) ; }
target:  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.