]> source.dussan.org Git - jgit.git/commitdiff
[spotbugs] FileReftableDatabase: extract lock to local variable 76/173376/7
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 4 Dec 2020 10:15:35 +0000 (11:15 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 22 Dec 2020 09:52:59 +0000 (10:52 +0100)
This fixes UL_UNRELEASED_LOCK_EXCEPTION_PATH raised by spotbugs in
#compactFully.

Change-Id: I370578ad9a027c5c9709d60a1dfafdac0cfca908
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java

index e613a58062c3c1c3cdbf52a65ef420f11ac73a67..ad1e753128808fdc1d4f13d8bbc08ad6eb133751 100644 (file)
@@ -22,6 +22,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeSet;
+import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.stream.Collectors;
 
@@ -107,12 +108,13 @@ public class FileReftableDatabase extends RefDatabase {
         * @throws IOException on I/O errors
         */
        public void compactFully() throws IOException {
-               reftableDatabase.getLock().lock();
+               Lock l = reftableDatabase.getLock();
+               l.lock();
                try {
                        reftableStack.compactFully();
                        reftableDatabase.clearCache();
                } finally {
-                       reftableDatabase.getLock().unlock();
+                       l.unlock();
                }
        }