This fixes UL_UNRELEASED_LOCK_EXCEPTION_PATH raised by spotbugs in
#DfsReftableDatabase and #clearCache.
Change-Id: Ifd3189288d2a8e64139c02cd105eb335fa2f68cf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.jgit.annotations.Nullable;
reftableDatabase = new ReftableDatabase() {
@Override
public MergedReftable openMergedReftable() throws IOException {
- DfsReftableDatabase.this.getLock().lock();
+ Lock l = DfsReftableDatabase.this.getLock();
+ l.lock();
try {
return new MergedReftable(stack().readers());
} finally {
- DfsReftableDatabase.this.getLock().unlock();
+ l.unlock();
}
}
};
@Override
void clearCache() {
- getLock().lock();
+ ReentrantLock l = getLock();
+ l.lock();
try {
if (ctx != null) {
ctx.close();
stack = null;
}
} finally {
- getLock().unlock();
+ l.unlock();
}
}