]> source.dussan.org Git - jgit.git/commitdiff
DfsBlockCache#creditSpace: release clockLock in finally block 91/112991/2
authorDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 7 Dec 2017 08:25:58 +0000 (17:25 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 7 Dec 2017 11:02:59 +0000 (20:02 +0900)
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>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlockCache.java

index a96be4a7fc10b5407dd9324dcbe9d8eeb675ce7c..03947d8395f63356671e367e07d79019a5dcde62 100644 (file)
@@ -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")