Browse Source

DfsBlockCache#creditSpace: release clockLock in finally block

Enclose the call to getStat in a `try`, and release the previously
acquired lock in the `finally`. This prevents that the lock is left
unreleased in the case of an exception being raised in getStat.

Change-Id: I17b4cd134dae887e23a1165253be0ac2d4fd452c
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.10
David Pursehouse 7 years ago
parent
commit
c89a11213e
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java

@ -418,8 +418,11 @@ public final class DfsBlockCache {
private void creditSpace(int credit, DfsStreamKey key) { private void creditSpace(int credit, DfsStreamKey key) {
clockLock.lock(); clockLock.lock();
getStat(liveBytes, key).addAndGet(-credit); try {
clockLock.unlock(); getStat(liveBytes, key).addAndGet(-credit);
} finally {
clockLock.unlock();
}
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

Loading…
Cancel
Save