diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2017-12-07 17:25:58 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2017-12-07 20:02:59 +0900 |
commit | c89a11213e7c3c39548f2f9b9a16c68b78783df8 (patch) | |
tree | cde94a9bcb6c721d6160f523819e56d94995abac | |
parent | 0ea73f6282c158db144785b4fa809173098b9ebe (diff) | |
download | jgit-c89a11213e7c3c39548f2f9b9a16c68b78783df8.tar.gz jgit-c89a11213e7c3c39548f2f9b9a16c68b78783df8.zip |
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>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java index a96be4a7fc..03947d8395 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java +++ b/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) { clockLock.lock(); - getStat(liveBytes, key).addAndGet(-credit); - clockLock.unlock(); + try { + getStat(liveBytes, key).addAndGet(-credit); + } finally { + clockLock.unlock(); + } } @SuppressWarnings("unchecked") |