Apache Lucene open-source search software
SOLR-9764: change getLiveDocs to do a single volatile read
yonik98d1dabcd8c8
diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.javaindex ff7054b2f5b..de6950b2a64 100644--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java@@ -1153,11 +1153,12 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrIpublic BitDocSet getLiveDocs() throws IOException {// Going through the filter cache will provide thread safety here if we only had getLiveDocs,// but the addition of setLiveDocs means we needed to add volatile to "liveDocs".- if (liveDocs == null) {- liveDocs = getDocSetBits(matchAllDocsQuery);+ BitDocSet docs = liveDocs;+ if (docs == null) {+ liveDocs = docs = getDocSetBits(matchAllDocsQuery);}- assert liveDocs.size() == numDocs();- return liveDocs;+ assert docs.size() == numDocs();+ return docs;}/** @lucene.internal */