Source:
<code>public synchronized UnlockStatus unlock( final String label ) { String ownerName = getLockReservationName(); LockOwnerInfo lockOwnerInfo = locks.get( ownerName ); if ( lockOwnerInfo == null ) { logger.trace( "Not locked by: {}. Returning null.", ownerName ); return null; } lockOwnerInfo.locks.remove( label ); int count = lockOwnerInfo.locks.size(); logger.trace( "Decremented lock count.\n Path: {}\n for owner: {}\n New count is: {}\nLock Info:\n{}", this.path, ownerName, count, getLockInfo() ); if ( count < 1 ) { locks.remove( ownerName ); if ( dominantOwner.equals( ownerName ) ) { logger.trace( "Unlocked owner is removed, but was dominant lock holder. Calculating new dominant lock holder." ); Optional<LockOwnerInfo> first = locks.values() .stream() .sorted( ( o1, o2 ) -> new Integer( o2.level.ordinal() ).compareTo( o1.level.ordinal() ) ) .findFirst(); if ( first.isPresent() ) { LockOwnerInfo newDom = first.get(); this.dominantOwner = newDom.ownerName; this.dominantLockLevel = newDom.level; logger.trace( "New dominant holder is: with level: {}", this.dominantOwner, this.dominantLockLevel ); <START> return new UnlockStatus( true, true, this.dominantLockLevel ); <END> } else { logger.trace( "Locks seems to be empty; Unlocking" ); this.dominantOwner = null; this.dominantLockLevel = null; return new UnlockStatus( true, true, null ); } } return new UnlockStatus( true, false, this.dominantLockLevel ); } logger.trace( "Unlock operation did not free final lock from file" ); return new UnlockStatus( false, false, this.dominantLockLevel ); }</code><technical_language>I new dominant lock level is one, owner replaced a new dominant owner...we check setting isChanged field correctly</technical_language>

Target:
public synchronized UnlockStatus unlock( final String label ) { String ownerName = getLockReservationName(); LockOwnerInfo lockOwnerInfo = locks.get( ownerName ); if ( lockOwnerInfo == null ) { logger.trace( "Not locked by: {}. Returning null.", ownerName ); return new UnlockStatus( false, false, null ); } lockOwnerInfo.locks.remove( label ); int count = lockOwnerInfo.locks.size(); logger.trace( "Decremented lock count.\n Path: {}\n for owner: {}\n New count is: {}\nLock Info:\n{}", this.path, ownerName, count, getLockInfo() ); if ( count < 1 ) { locks.remove( ownerName ); if ( dominantOwner.equals( ownerName ) ) { logger.trace( "Unlocked owner is removed, but was dominant lock holder. Calculating new dominant lock holder." ); Optional<LockOwnerInfo> first = locks.values() .stream() .sorted( ( o1, o2 ) -> new Integer( o2.level.ordinal() ).compareTo( o1.level.ordinal() ) ) .findFirst(); if ( first.isPresent() ) { LockOwnerInfo newDom = first.get(); this.dominantOwner = newDom.ownerName; boolean changed = ( this.dominantLockLevel != newDom.level ); this.dominantLockLevel = newDom.level; logger.trace( "New dominant holder is: with level: {}", this.dominantOwner, this.dominantLockLevel ); return new UnlockStatus( true, changed, this.dominantLockLevel ); } else { logger.trace( "Locks seems to be empty; Unlocking" ); this.dominantOwner = null; this.dominantLockLevel = null; return new UnlockStatus( true, true, null ); } } return new UnlockStatus( true, false, this.dominantLockLevel ); } logger.trace( "Unlock operation did not free final lock from file" ); return new UnlockStatus( false, false, this.dominantLockLevel ); }