If we just cleared a Reference from the queue than there is a good
chance that there is a dead Entry cell in the hash table's bucket
for this position. If we find one that matches we know we should
clear out that chain.
Signed-off-by: Shawn O. Pearce <redacted>
---
.../src/org/spearce/jgit/lib/OffsetCache.java | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java
index 170c5d2..12912d9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/OffsetCache.java
@@ -418,8 +418,22 @@ private void gc() {
// skew the resource counters we maintain. Our canClear() check here
// provides a way to skip the redundant dequeues, if any.
//
- if (r.canClear())
+ if (r.canClear()) {
clear(r);
+
+ boolean found = false;
+ final int s = slot(r.pack, r.position);
+ final Entry<V> e1 = table.get(s);
+ for (Entry<V> n = e1; n != null; n = n.next) {
+ if (n.ref == r) {
+ n.dead = true;
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ table.compareAndSet(s, e1, clean(e1));
+ }
}
}
--
1.6.3.rc1.205.g37f8