Remove obsolete code in ConcurrentReferenceHashMapTests

This commit is contained in:
Sam Brannen 2023-11-04 14:38:30 +01:00
parent 12078e6ec5
commit ed49f86dfb
1 changed files with 0 additions and 20 deletions

View File

@ -509,11 +509,6 @@ class ConcurrentReferenceHashMapTests {
map.createReferenceManager().createReference(null, 1234, null); map.createReferenceManager().createReference(null, 1234, null);
} }
private interface ValueFactory<V> {
V newValue(int k);
}
private static class TestWeakConcurrentCache<K, V> extends ConcurrentReferenceHashMap<K, V> { private static class TestWeakConcurrentCache<K, V> extends ConcurrentReferenceHashMap<K, V> {
@ -521,16 +516,10 @@ class ConcurrentReferenceHashMapTests {
private final LinkedList<MockReference<K, V>> queue = new LinkedList<>(); private final LinkedList<MockReference<K, V>> queue = new LinkedList<>();
private boolean disableTestHooks;
public TestWeakConcurrentCache() { public TestWeakConcurrentCache() {
super(); super();
} }
public void setDisableTestHooks(boolean disableTestHooks) {
this.disableTestHooks = disableTestHooks;
}
public TestWeakConcurrentCache(int initialCapacity, float loadFactor, int concurrencyLevel) { public TestWeakConcurrentCache(int initialCapacity, float loadFactor, int concurrencyLevel) {
super(initialCapacity, loadFactor, concurrencyLevel); super(initialCapacity, loadFactor, concurrencyLevel);
} }
@ -541,9 +530,6 @@ class ConcurrentReferenceHashMapTests {
@Override @Override
protected int getHash(@Nullable Object o) { protected int getHash(@Nullable Object o) {
if (this.disableTestHooks) {
return super.getHash(o);
}
// For testing we want more control of the hash // For testing we want more control of the hash
this.supplementalHash = super.getHash(o); this.supplementalHash = super.getHash(o);
return (o != null ? o.hashCode() : 0); return (o != null ? o.hashCode() : 0);
@ -558,16 +544,10 @@ class ConcurrentReferenceHashMapTests {
return new ReferenceManager() { return new ReferenceManager() {
@Override @Override
public Reference<K, V> createReference(Entry<K, V> entry, int hash, @Nullable Reference<K, V> next) { public Reference<K, V> createReference(Entry<K, V> entry, int hash, @Nullable Reference<K, V> next) {
if (TestWeakConcurrentCache.this.disableTestHooks) {
return super.createReference(entry, hash, next);
}
return new MockReference<>(entry, hash, next, TestWeakConcurrentCache.this.queue); return new MockReference<>(entry, hash, next, TestWeakConcurrentCache.this.queue);
} }
@Override @Override
public Reference<K, V> pollForPurge() { public Reference<K, V> pollForPurge() {
if (TestWeakConcurrentCache.this.disableTestHooks) {
return super.pollForPurge();
}
return TestWeakConcurrentCache.this.queue.isEmpty() ? null : TestWeakConcurrentCache.this.queue.removeFirst(); return TestWeakConcurrentCache.this.queue.isEmpty() ? null : TestWeakConcurrentCache.this.queue.removeFirst();
} }
}; };