You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2019/10/03 19:12:23 UTC
[lucene-solr] branch master updated: SOLR-8241: Fix an NPE.
This is an automated email from the ASF dual-hosted git repository.
ab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new a0396da SOLR-8241: Fix an NPE.
a0396da is described below
commit a0396da64b5874886a801f22b7cb81e11ed9642a
Author: Andrzej Bialecki <ab...@apache.org>
AuthorDate: Thu Oct 3 21:11:44 2019 +0200
SOLR-8241: Fix an NPE.
---
.../java/org/apache/solr/search/CaffeineCache.java | 42 +++++++++++-----------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/search/CaffeineCache.java b/solr/core/src/java/org/apache/solr/search/CaffeineCache.java
index ad4571d..71eb86f 100644
--- a/solr/core/src/java/org/apache/solr/search/CaffeineCache.java
+++ b/solr/core/src/java/org/apache/solr/search/CaffeineCache.java
@@ -76,7 +76,7 @@ public class CaffeineCache<K, V> extends SolrCacheBase implements SolrCache<K, V
private CacheStats priorStats;
private long priorInserts;
- private String description;
+ private String description = "Caffeine Cache";
private LongAdder inserts;
private Cache<K,V> cache;
private long warmupTime;
@@ -340,25 +340,27 @@ public class CaffeineCache<K, V> extends SolrCacheBase implements SolrCache<K, V
public void initializeMetrics(SolrMetricManager manager, String registryName, String tag, String scope) {
registry = manager.registry(registryName);
cacheMap = new MetricsMap((detailed, map) -> {
- CacheStats stats = cache.stats();
- long insertCount = inserts.sum();
-
- map.put(LOOKUPS_PARAM, stats.requestCount());
- map.put(HITS_PARAM, stats.hitCount());
- map.put(HIT_RATIO_PARAM, stats.hitRate());
- map.put(INSERTS_PARAM, insertCount);
- map.put(EVICTIONS_PARAM, stats.evictionCount());
- map.put(SIZE_PARAM, cache.asMap().size());
- map.put("warmupTime", warmupTime);
- map.put(RAM_BYTES_USED_PARAM, ramBytesUsed());
- map.put(MAX_RAM_MB_PARAM, getMaxRamMB());
-
- CacheStats cumulativeStats = priorStats.plus(stats);
- map.put("cumulative_lookups", cumulativeStats.requestCount());
- map.put("cumulative_hits", cumulativeStats.hitCount());
- map.put("cumulative_hitratio", cumulativeStats.hitRate());
- map.put("cumulative_inserts", priorInserts + insertCount);
- map.put("cumulative_evictions", cumulativeStats.evictionCount());
+ if (cache != null) {
+ CacheStats stats = cache.stats();
+ long insertCount = inserts.sum();
+
+ map.put(LOOKUPS_PARAM, stats.requestCount());
+ map.put(HITS_PARAM, stats.hitCount());
+ map.put(HIT_RATIO_PARAM, stats.hitRate());
+ map.put(INSERTS_PARAM, insertCount);
+ map.put(EVICTIONS_PARAM, stats.evictionCount());
+ map.put(SIZE_PARAM, cache.asMap().size());
+ map.put("warmupTime", warmupTime);
+ map.put(RAM_BYTES_USED_PARAM, ramBytesUsed());
+ map.put(MAX_RAM_MB_PARAM, getMaxRamMB());
+
+ CacheStats cumulativeStats = priorStats.plus(stats);
+ map.put("cumulative_lookups", cumulativeStats.requestCount());
+ map.put("cumulative_hits", cumulativeStats.hitCount());
+ map.put("cumulative_hitratio", cumulativeStats.hitRate());
+ map.put("cumulative_inserts", priorInserts + insertCount);
+ map.put("cumulative_evictions", cumulativeStats.evictionCount());
+ }
});
manager.registerGauge(this, registryName, cacheMap, tag, true, scope, getCategory().toString());
}