Source:
private Lock getRepositoryLock( Repository repository, boolean exclusive ) { final String lockName = exclusive ? "exclusive" : "shared"; Thread deleteThread = deleteThreads.get( repository.getId() ); if ( deleteThread != null && deleteThread != Thread.currentThread() ) { logger.debug( "Could not acquire lock on repository {}. The repository is being deleted by thread {}.", lockName, repository.getId(), deleteThread.getName() ); return null; } ReadWriteLock rwlock; synchronized ( repositoryLocks ) { rwlock = repositoryLocks.get( repository.getId() ); if ( rwlock == null ) { rwlock = NamedReadWriteLock.decorate( new ReentrantReadWriteLock(), repository.getId() ); repositoryLocks.put( repository.getId(), rwlock ); } } try { Lock lock = exclusive ? rwlock.writeLock() : rwlock.readLock(); if ( lock.tryLock( lockTimeoutSeconds, TimeUnit.SECONDS ) ) { return lock; } if ( logger.isDebugEnabled() ) { logger.warn( "Could not acquire lock on repository in seconds. " + "Consider increasing value of ''nexus.indexer.locktimeout'' parameter. " + "The operation has been aborted.", lockName, repository.getId(), lockTimeoutSeconds, new Exception( ARTIFICIAL_EXCEPTION ) ); } else { logger.warn( "Could not acquire lock on repository in seconds. " + "Consider increasing value of ''nexus.indexer.locktimeout'' parameter. " + "Enable debug log to recieve more information.", lockName, repository.getId(), lockTimeoutSeconds ); } } catch ( InterruptedException e ) { logger.debug( "Interrupted lock request on repository {}", lockName, repository.getId(), new Exception( ARTIFICIAL_EXCEPTION ) ); } return null; }

Target:
private Lock getRepositoryLock( Repository repository, boolean exclusive ) { final String lockName = exclusive ? "exclusive" : "shared"; Thread deleteThread = deleteThreads.get( repository.getId() ); if ( deleteThread != null && deleteThread != Thread.currentThread() ) { logger.debug( "Could not acquire lock on repository {}. The repository is being deleted by thread {}.", lockName, repository.getId(), deleteThread.getName() ); return null; } ReadWriteLock rwlock; synchronized ( repositoryLocks ) { rwlock = repositoryLocks.get( repository.getId() ); if ( rwlock == null ) { rwlock = NamedReadWriteLock.decorate( new ReentrantReadWriteLock(), repository.getId() ); repositoryLocks.put( repository.getId(), rwlock ); } } try { Lock lock = exclusive ? rwlock.writeLock() : rwlock.readLock(); if ( lock.tryLock( lockTimeoutSeconds, TimeUnit.SECONDS ) ) { return lock; } if ( logger.isDebugEnabled() ) { logger.warn( "Could not acquire lock on repository in seconds. " + "Consider increasing value of ''nexus.indexer.locktimeout'' parameter. " + "The operation has been aborted.", lockName, repository.getId(), lockTimeoutSeconds, new Exception( ARTIFICIAL_EXCEPTION ) ); } else { logger.warn( "Could not acquire lock on repository in seconds. " + "Consider increasing value of ''nexus.indexer.locktimeout'' parameter. " + "Enable debug log to recieve more information.", lockName, repository.getId(), lockTimeoutSeconds ); } } catch ( InterruptedException e ) { logger.debug( "Interrupted lock request on repository {}", lockName, repository.getId(), new Exception( ARTIFICIAL_EXCEPTION ) ); } return null; }