]> source.dussan.org Git - jgit.git/commitdiff
DfsBlockCache: Fix NPE when evicting empty cell 72/4572/1
authorShawn O. Pearce <spearce@spearce.org>
Tue, 8 Nov 2011 20:22:37 +0000 (12:22 -0800)
committerShawn O. Pearce <spearce@spearce.org>
Tue, 8 Nov 2011 20:23:44 +0000 (12:23 -0800)
The cache starts with a single empty Ref that has no data, as the
clock list does not support being empty. When this Ref is removed,
the size has to be decremented from the associated DfsPackKey,
which was previously null. Make it always be non-null.

Change-Id: I2af99903e8039405ea6d67f383576ffa43839cff

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

index d3dadbe2959e539b5bc9bae00fa0e38e520be57d..e8733701df620e5e80e8a500b4bde2d63a1735af 100644 (file)
@@ -206,7 +206,7 @@ public final class DfsBlockCache {
                blockSizeShift = Integer.numberOfTrailingZeros(blockSize);
 
                clockLock = new ReentrantLock(true /* fair */);
-               clockHand = new Ref<Object>(null, -1, 0, null);
+               clockHand = new Ref<Object>(new DfsPackKey(), -1, 0, null);
                clockHand.next = clockHand;
 
                readAheadLimit = cfg.getReadAheadLimit();