From b5bf3b9c3844a739ef5b2f6317480b37dd0fe47b Mon Sep 17 00:00:00 2001 From: Erick Erickson Date: Mon, 12 Feb 2018 19:25:13 -0800 Subject: [PATCH] SOLR-11898: ConcurrentModificationException when calling org.apache.solr.core.SolrInfoBean.getMetricsSnapshot --- solr/CHANGES.txt | 3 +++ solr/core/src/java/org/apache/solr/search/FastLRUCache.java | 4 ++-- solr/core/src/java/org/apache/solr/search/LFUCache.java | 4 ++-- solr/core/src/java/org/apache/solr/search/LRUCache.java | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 2f6005f65f8..3a6f9054597 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -200,6 +200,9 @@ Bug Fixes * SOLR-10261: In case of in-place updates, failure in leader to follower replica update request now throws the follower replica in leader-initiated-recovery (Ishan Chattopadhyaya, Steve Rowe) +* SOLR-11898: ConcurrentModificationException when calling org.apache.solr.core.SolrInfoBean.getMetricsSnapshot + (Jeff Miller via Erick Erickson) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/search/FastLRUCache.java b/solr/core/src/java/org/apache/solr/search/FastLRUCache.java index 1cf4443c912..b2e56a81f52 100644 --- a/solr/core/src/java/org/apache/solr/search/FastLRUCache.java +++ b/solr/core/src/java/org/apache/solr/search/FastLRUCache.java @@ -25,7 +25,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.invoke.MethodHandles; -import java.util.HashSet; +import java.util.concurrent.ConcurrentHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -60,7 +60,7 @@ public class FastLRUCache extends SolrCacheBase implements SolrCache private long maxRamBytes; private MetricsMap cacheMap; - private Set metricNames = new HashSet<>(); + private Set metricNames = ConcurrentHashMap.newKeySet(); private MetricRegistry registry; @Override diff --git a/solr/core/src/java/org/apache/solr/search/LFUCache.java b/solr/core/src/java/org/apache/solr/search/LFUCache.java index f502b03600b..7d41ae343ff 100644 --- a/solr/core/src/java/org/apache/solr/search/LFUCache.java +++ b/solr/core/src/java/org/apache/solr/search/LFUCache.java @@ -17,7 +17,7 @@ package org.apache.solr.search; import java.lang.invoke.MethodHandles; -import java.util.HashSet; +import java.util.concurrent.ConcurrentHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -65,7 +65,7 @@ public class LFUCache implements SolrCache { private int showItems = 0; private Boolean timeDecay = true; private MetricsMap cacheMap; - private Set metricNames = new HashSet<>(); + private Set metricNames = ConcurrentHashMap.newKeySet(); private MetricRegistry registry; @Override diff --git a/solr/core/src/java/org/apache/solr/search/LRUCache.java b/solr/core/src/java/org/apache/solr/search/LRUCache.java index cbd3979155d..af05dadd7d4 100644 --- a/solr/core/src/java/org/apache/solr/search/LRUCache.java +++ b/solr/core/src/java/org/apache/solr/search/LRUCache.java @@ -19,7 +19,7 @@ package org.apache.solr.search; import java.lang.invoke.MethodHandles; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; +import java.util.concurrent.ConcurrentHashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; @@ -87,7 +87,7 @@ public class LRUCache extends SolrCacheBase implements SolrCache, Acco private Map map; private String description="LRU Cache"; private MetricsMap cacheMap; - private Set metricNames = new HashSet<>(); + private Set metricNames = ConcurrentHashMap.newKeySet(); private MetricRegistry registry; private long maxRamBytes = Long.MAX_VALUE;