summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2017-09-04 14:35:58 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2017-09-04 14:35:58 -0400
commitde4e0acc301cbfaf55ba133cbc4f69dd7c53d62f (patch)
tree0480565551d5077aee20748120b429f356c97d39
parent6d27869659e1a3436438ddbb18114f7c8dab6aed (diff)
parent39b193b6f4b72bd6c08170f53001e7cfdaa51318 (diff)
downloadjgit-de4e0acc301cbfaf55ba133cbc4f69dd7c53d62f.tar.gz
jgit-de4e0acc301cbfaf55ba133cbc4f69dd7c53d62f.zip
Merge "Remove workaround for bug in Java's ReferenceQueue"
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java42
1 files changed, 9 insertions, 33 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
index a525c85116..61960068be 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java
@@ -496,31 +496,16 @@ public class WindowCache {
private void gc() {
Ref r;
while ((r = (Ref) queue.poll()) != null) {
- // Sun's Java 5 and 6 implementation have a bug where a Reference
- // can be enqueued and dequeued twice on the same reference queue
- // due to a race condition within ReferenceQueue.enqueue(Reference).
- //
- // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6837858
- //
- // We CANNOT permit a Reference to come through us twice, as it will
- // skew the resource counters we maintain. Our canClear() check here
- // provides a way to skip the redundant dequeues, if any.
- //
- if (r.canClear()) {
- clear(r);
-
- boolean found = false;
- final int s = slot(r.pack, r.position);
- final Entry e1 = table.get(s);
- for (Entry n = e1; n != null; n = n.next) {
- if (n.ref == r) {
- n.dead = true;
- found = true;
- break;
- }
- }
- if (found)
+ clear(r);
+
+ final int s = slot(r.pack, r.position);
+ final Entry e1 = table.get(s);
+ for (Entry n = e1; n != null; n = n.next) {
+ if (n.ref == r) {
+ n.dead = true;
table.compareAndSet(s, e1, clean(e1));
+ break;
+ }
}
}
}
@@ -581,8 +566,6 @@ public class WindowCache {
long lastAccess;
- private boolean cleared;
-
protected Ref(final PackFile pack, final long position,
final ByteWindow v, final ReferenceQueue<ByteWindow> queue) {
super(v, queue);
@@ -590,13 +573,6 @@ public class WindowCache {
this.position = position;
this.size = v.size();
}
-
- final synchronized boolean canClear() {
- if (cleared)
- return false;
- cleared = true;
- return true;
- }
}
private static final class Lock {