This is an automated email from the ASF dual-hosted git repository.
iamsanjay pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new fc4429a7525 Fix TestCaffeineCache and TestThinCache testSimple
failures with Caffein 3.3.0 (#5207)
fc4429a7525 is described below
commit fc4429a7525440125bb72ee969672ab5d78739b8
Author: Sanjay Dutt <[email protected]>
AuthorDate: Fri Oct 23 21:06:18 2026 +0530
Fix TestCaffeineCache and TestThinCache testSimple failures with Caffein
3.3.0 (#5207)
---
solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java | 7 ++++---
solr/core/src/test/org/apache/solr/search/TestThinCache.java | 9 +++++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java
b/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java
index b4c69600fbd..13f8a30153e 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCaffeineCache.java
@@ -70,8 +70,9 @@ public class TestCaffeineCache extends SolrTestCase {
assertEquals(3L, nl.get("lookups"));
assertEquals(2L, nl.get("hits"));
assertEquals(101L, nl.get("inserts"));
-
- assertNull(lfuCache.get(1)); // first item put in should be the first out
+ // Exactly one entry is evicted; which one is up to Caffeine's eviction
policy.
+ assertEquals(100, lfuCache.size());
+ assertEquals(1L, nl.get("evictions"));
// Test autowarming
newLFUCache.init(params, initObj, regenerator);
@@ -88,7 +89,7 @@ public class TestCaffeineCache extends SolrTestCase {
assertEquals(1L, nl.get("inserts"));
assertEquals(0L, nl.get("evictions"));
- assertEquals(7L, nl.get("cumulative_lookups"));
+ assertEquals(6L, nl.get("cumulative_lookups"));
assertEquals(4L, nl.get("cumulative_hits"));
assertEquals(102L, nl.get("cumulative_inserts"));
}
diff --git a/solr/core/src/test/org/apache/solr/search/TestThinCache.java
b/solr/core/src/test/org/apache/solr/search/TestThinCache.java
index 6de790500ee..8b0bd339431 100644
--- a/solr/core/src/test/org/apache/solr/search/TestThinCache.java
+++ b/solr/core/src/test/org/apache/solr/search/TestThinCache.java
@@ -127,7 +127,12 @@ public class TestThinCache extends SolrTestCaseJ4 {
assertEquals(2L, nl.get("hits"));
assertEquals(101L, nl.get("inserts"));
- assertNull(lfuCache.get(1)); // first item put in should be the first out
+ // Exactly one entry is evicted; which one is up to Caffeine's eviction
policy.
+ // lfuCache isn't registered for removals here, so check the backing
cache's size.
+ assertEquals(100, backing.size());
+
+ // The backing is full; make room so warming doesn't evict the new cache's
own entries.
+ backing.setMaxSize(200);
// Test autowarming
newLFUCache.init(Collections.singletonMap("autowarmCount", "25"), initObj,
regenerator);
@@ -144,7 +149,7 @@ public class TestThinCache extends SolrTestCaseJ4 {
assertEquals(1L, nl.get("inserts"));
assertEquals(0L, nl.get("evictions"));
- assertEquals(7L, nl.get("cumulative_lookups"));
+ assertEquals(6L, nl.get("cumulative_lookups"));
assertEquals(4L, nl.get("cumulative_hits"));
assertEquals(102L, nl.get("cumulative_inserts"));
}