Skip to content

Apache Lucene open-source search software

SOLR-10141: Upgrade to Caffeine 2.3.5 to fix issues with removal listener

yonik6804f3694210
diff --git a/lucene/ivy-versions.properties b/lucene/ivy-versions.properties
index 172b95bb100..1c519d29287 100644
--- a/lucene/ivy-versions.properties
+++ b/lucene/ivy-versions.properties
@@ -23,7 +23,7 @@ com.fasterxml.jackson.core.version = 2.5.4
/com.fasterxml.jackson.core/jackson-databind = ${com.fasterxml.jackson.core.version}
/com.fasterxml.jackson.dataformat/jackson-dataformat-smile = ${com.fasterxml.jackson.core.version}
-/com.github.ben-manes.caffeine/caffeine = 1.0.1
+/com.github.ben-manes.caffeine/caffeine = 2.3.5
/com.google.guava/guava = 14.0.1
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index bd81afa267d..f17018dceb5 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -162,6 +162,9 @@ Bug Fixes
* SOLR-10121: Fix race conditions in HDFS BlockCache that can contribute to corruption in high
concurrency situations. (yonik)
+* SOLR-10141: Upgrade to Caffeine 2.3.5 since v1.0.1 contributed to BlockCache corruption because the
+ removal listener was called more than once for some items and not at all for other items. (Ben Manes, yonik)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java b/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java
index 20d2721bdcf..b7747827010 100644
--- a/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java
+++ b/solr/core/src/java/org/apache/solr/store/blockcache/BlockCache.java
@@ -75,8 +75,8 @@ public class BlockCache {
lockCounters[i] = new AtomicInteger();
}
- RemovalListener<BlockCacheKey,BlockCacheLocation> listener =
- notification -> releaseLocation(notification.getKey(), notification.getValue());
+ RemovalListener<BlockCacheKey,BlockCacheLocation> listener = (blockCacheKey, blockCacheLocation, removalCause) -> releaseLocation(blockCacheKey, blockCacheLocation);
+
cache = Caffeine.newBuilder()
.removalListener(listener)
.maximumSize(maxEntries)
diff --git a/solr/licenses/caffeine-1.0.1.jar.sha1 b/solr/licenses/caffeine-1.0.1.jar.sha1
deleted file mode 100644
index f8e75fde720..00000000000
--- a/solr/licenses/caffeine-1.0.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-eb95a1eb55cb02018b8e0bc1609ce569b455ea98
diff --git a/solr/licenses/caffeine-2.3.5.jar.sha1 b/solr/licenses/caffeine-2.3.5.jar.sha1
new file mode 100644
index 00000000000..128fe1adf2d
--- /dev/null
+++ b/solr/licenses/caffeine-2.3.5.jar.sha1
@@ -0,0 +1 @@
+672d74bd3fb0611f671ea4bf65e278c8a5d4af3c