SOLR-9764: change getLiveDocs to do a single volatile read

This commit is contained in:
yonik 2017-02-02 21:49:09 -05:00
parent 52b1ae33a1
commit 98d1dabcd8
1 changed files with 5 additions and 4 deletions

View File

@ -1153,11 +1153,12 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
public 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 */