* @param forThread
* thread for which lock depth is being decreased
* @return remaining depth of this lock
*/
private int decrementLock(File file, Thread forThread) {
ConcurrentHashMap locksPerThread = (ConcurrentHashMap) currentLockHolders.get(file);
if (locksPerThread == null) {
throw new RuntimeException("Calling decrementLock on a thread which holds no locks");
}
Integer c = (Integer) locksPerThread.get(forThread);
int oldHeldLocks = c == null ? 0 : c.intValue();
if (oldHeldLocks <= 0) {
throw new RuntimeException("Calling decrementLock on a thread which holds no locks");
}
int newHeldLocks = oldHeldLocks - 1;
if (newHeldLocks > 0) {
locksPerThread.put(forThread, new Integer(newHeldLocks));
} else {
locksPerThread.remove(forThread);
}
return newHeldLocks;
}