Skip to content

Commit

Permalink
Fix flaky DefaultPoolTest
Browse files Browse the repository at this point in the history
The `claimWhenInterruptedMustNotThrowIfObjectIsAvailableViaCache` relies on the thread-local cache having a previously claimed object ready to be reclaimed.
However, background expiration checking would sometimes race and claim the object temporarily, preventing a TLR_CLAIM by the test.
This would cause the test to go down the slow claim path, which is susceptible to interrupts, and which the test was asserting would not happen.
  • Loading branch information
chrisvest committed May 27, 2024
1 parent d488d84 commit ce152e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/test/java/blackbox/DefaultPoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ class DefaultPoolTest extends ThreadBasedPoolTest {
protected PoolBuilder<GenericPoolable> 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);
}
}

0 comments on commit ce152e4

Please sign in to comment.