private CountingLock getKeyLock(final Object key) { assert key != null : "contract broken: key != null"; getStripedLock(key).tryLock(); try { final CountingLock result; final CountingLock previousLock = key2lock.get(key); if (previousLock == null) { result = new CountingLock(lockTimeout, lockTimeoutUnit); key2lock.put(key, result); } else { result = previousLock; } result.incrementUses(); return result; } finally { getStripedLock(key).unlock(); } }
private CountingLock getKeyLock(final Object key) { assert key != null : "contract broken: key != null"; getStripedLock(key).tryLock(); try { final CountingLock result; final CountingLock previousLock = key2lock.get(key); if (previousLock == null) { result = new CountingLock(lockTimeout, lockTimeoutUnit); key2lock.put(key, result); } else { result = previousLock; } result.incrementUses(); return result; } finally { getStripedLock(key).unlock(); } }