Apache Solr open-source search software
SOLR-14576 : Do not use SolrCore as keys in a WeakHashMap (#1586)
Noble Paul8c41418c0fb3
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex ab3eafe5f0b..f0bc220ed7c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -193,7 +193,7 @@ Improvements* SOLR-14905: Update commons-io version to 2.8.0 due to security vulnerability. (Nazerke Seidan via Bruno Roustant)-* SOLR-14691: Metrics reporting should avoid creating objects. (ab, Noble Paul)+* SOLR-14691: Metrics reporting should avoid creating objects. (ab, noble)Optimizations---------------------@@ -212,6 +212,8 @@ Optimizations* SOLR-14658: SolrJ's CollectionAdminRequest.collectionStatus(collection) would internally getall collection statuses instead of just the specified collection. (Andy Vuong)+* SOLR-14576 : Do not use SolrCore as keys in a WeakHashMap (noble)+Bug Fixes---------------------diff --git a/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java b/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.javaindex 9c1c70ff600..41a6ec51b61 100644--- a/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java+++ b/solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java@@ -20,6 +20,7 @@ import java.io.IOException;import java.nio.charset.StandardCharsets;import java.util.Collections;import java.util.List;+import java.util.UUID;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;@@ -54,7 +55,7 @@ public final class HttpCacheHeaderUtil {** @see #calcEtag*/- private static WeakIdentityMap<SolrCore, EtagCacheVal> etagCoreCache = WeakIdentityMap.newConcurrentHashMap();+ private static WeakIdentityMap<UUID, EtagCacheVal> etagCoreCache = WeakIdentityMap.newConcurrentHashMap();/** @see #etagCoreCache */private static class EtagCacheVal {@@ -89,12 +90,12 @@ public final class HttpCacheHeaderUtil {final long currentIndexVersion= solrReq.getSearcher().getIndexReader().getVersion();- EtagCacheVal etagCache = etagCoreCache.get(core);+ EtagCacheVal etagCache = etagCoreCache.get(core.uniqueId);if (null == etagCache) {final String etagSeed= core.getSolrConfig().getHttpCachingConfig().getEtagSeed();etagCache = new EtagCacheVal(etagSeed);- etagCoreCache.put(core, etagCache);+ etagCoreCache.put(core.uniqueId, etagCache);}return etagCache.calcEtag(currentIndexVersion);