diff --git a/src/test/java/blackbox/AllocatorBasedPoolTest.java b/src/test/java/blackbox/AllocatorBasedPoolTest.java index 25a976fd..fc473474 100644 --- a/src/test/java/blackbox/AllocatorBasedPoolTest.java +++ b/src/test/java/blackbox/AllocatorBasedPoolTest.java @@ -1681,13 +1681,14 @@ void mustNotHoldOnToDeallocatedObjectsWhenLeakDetectionIsEnabled() // Clear the allocator lists to remove the last references allocator.clearLists(); - // GC to force the object through finalization life cycle - System.gc(); - System.gc(); - System.gc(); + int iterationCount = 0; + do { + // GC to force the object through finalization life cycle + System.gc(); + assertThat(iterationCount++).isLessThan(1000); - // Now our weakReference must have been cleared - assertNull(weakReference.get()); + // Now our weakReference must eventually have been cleared + } while (weakReference.get() != null); } @Test diff --git a/src/test/java/blackbox/DefaultPoolTest.java b/src/test/java/blackbox/DefaultPoolTest.java index 55a061a9..146726f6 100644 --- a/src/test/java/blackbox/DefaultPoolTest.java +++ b/src/test/java/blackbox/DefaultPoolTest.java @@ -25,10 +25,4 @@ class DefaultPoolTest extends ThreadBasedPoolTest { protected PoolBuilder createInitialPoolBuilder(AlloKit.CountingAllocator allocator) { return Pool.from(allocator); } - - @Override - void claimWhenInterruptedMustNotThrowIfObjectIsAvailableViaCache(Taps taps) throws Exception { - noBackgroundExpirationChecking(); // Prevent background expiration checking from claiming cached object. - super.claimWhenInterruptedMustNotThrowIfObjectIsAvailableViaCache(taps); - } } diff --git a/src/test/java/blackbox/ThreadBasedPoolTest.java b/src/test/java/blackbox/ThreadBasedPoolTest.java index 1420e77d..8a7745f7 100644 --- a/src/test/java/blackbox/ThreadBasedPoolTest.java +++ b/src/test/java/blackbox/ThreadBasedPoolTest.java @@ -702,4 +702,22 @@ void newBgAllocatedObjectsMustBeClaimedAheadOfExistingLiveObjects(Taps taps) thr d.release(); } } + + @Override + void claimWhenInterruptedMustNotThrowIfObjectIsAvailableViaCache(Taps taps) throws Exception { + noBackgroundExpirationChecking(); // Prevent background expiration checking from claiming cached object. + super.claimWhenInterruptedMustNotThrowIfObjectIsAvailableViaCache(taps); + } + + @Override + void mustNotHoldOnToDeallocatedObjectsWhenLeakDetectionIsEnabled() throws Exception { + noBackgroundExpirationChecking(); + super.mustNotHoldOnToDeallocatedObjectsWhenLeakDetectionIsEnabled(); + } + + @Override + void tryClaimMustReturnIfPoolIsNotEmpty(Taps taps) throws Exception { + noBackgroundExpirationChecking(); + super.tryClaimMustReturnIfPoolIsNotEmpty(taps); + } }