@@ -509,28 +509,17 @@ void shouldSupportNullReference() {
509
509
map .createReferenceManager ().createReference (null , 1234 , null );
510
510
}
511
511
512
- private interface ValueFactory <V > {
513
-
514
- V newValue (int k );
515
- }
516
-
517
512
518
513
private static class TestWeakConcurrentCache <K , V > extends ConcurrentReferenceHashMap <K , V > {
519
514
520
515
private int supplementalHash ;
521
516
522
517
private final LinkedList <MockReference <K , V >> queue = new LinkedList <>();
523
518
524
- private boolean disableTestHooks ;
525
-
526
519
public TestWeakConcurrentCache () {
527
520
super ();
528
521
}
529
522
530
- public void setDisableTestHooks (boolean disableTestHooks ) {
531
- this .disableTestHooks = disableTestHooks ;
532
- }
533
-
534
523
public TestWeakConcurrentCache (int initialCapacity , float loadFactor , int concurrencyLevel ) {
535
524
super (initialCapacity , loadFactor , concurrencyLevel );
536
525
}
@@ -541,9 +530,6 @@ public TestWeakConcurrentCache(int initialCapacity, int concurrencyLevel) {
541
530
542
531
@ Override
543
532
protected int getHash (@ Nullable Object o ) {
544
- if (this .disableTestHooks ) {
545
- return super .getHash (o );
546
- }
547
533
// For testing we want more control of the hash
548
534
this .supplementalHash = super .getHash (o );
549
535
return (o != null ? o .hashCode () : 0 );
@@ -558,16 +544,10 @@ protected ReferenceManager createReferenceManager() {
558
544
return new ReferenceManager () {
559
545
@ Override
560
546
public Reference <K , V > createReference (Entry <K , V > entry , int hash , @ Nullable Reference <K , V > next ) {
561
- if (TestWeakConcurrentCache .this .disableTestHooks ) {
562
- return super .createReference (entry , hash , next );
563
- }
564
547
return new MockReference <>(entry , hash , next , TestWeakConcurrentCache .this .queue );
565
548
}
566
549
@ Override
567
550
public Reference <K , V > pollForPurge () {
568
- if (TestWeakConcurrentCache .this .disableTestHooks ) {
569
- return super .pollForPurge ();
570
- }
571
551
return TestWeakConcurrentCache .this .queue .isEmpty () ? null : TestWeakConcurrentCache .this .queue .removeFirst ();
572
552
}
573
553
};
0 commit comments