From: Shawn O. Pearce Date: Tue, 8 Nov 2011 20:22:37 +0000 (-0800) Subject: DfsBlockCache: Fix NPE when evicting empty cell X-Git-Tag: v1.2.0.201112221803-r~42^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F72%2F4572%2F1;p=jgit.git DfsBlockCache: Fix NPE when evicting empty cell 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 --- diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsBlockCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsBlockCache.java index d3dadbe295..e8733701df 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsBlockCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsBlockCache.java @@ -206,7 +206,7 @@ public final class DfsBlockCache { blockSizeShift = Integer.numberOfTrailingZeros(blockSize); clockLock = new ReentrantLock(true /* fair */); - clockHand = new Ref(null, -1, 0, null); + clockHand = new Ref(new DfsPackKey(), -1, 0, null); clockHand.next = clockHand; readAheadLimit = cfg.getReadAheadLimit();