Apache Lucene open-source search software
SOLR-2861: use searcherLock in getIndexDir
Yonik Seeley36962d9a9e99
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 146b2efa615..5ddbbf23f19 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -401,6 +401,10 @@ Bug Fixes* SOLR-2791: Replication: abortfetch command is broken if replication was startedby fetchindex command instead of a regular poll (Yury Kats via shalin)+* SOLR-2861: Fix extremely rare race condition on commit that can result+ in a NPE (yonik)++Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.javaindex 42ab59cfff6..e5524221162 100644--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java@@ -151,10 +151,12 @@ public final class SolrCore implements SolrInfoMBean {}public String getIndexDir() {- if (_searcher == null)- return dataDir + "index/";- SolrIndexSearcher searcher = _searcher.get();- return searcher.getIndexDir() == null ? dataDir + "index/" : searcher.getIndexDir();+ synchronized (searcherLock) {+ if (_searcher == null)+ return dataDir + "index/";+ SolrIndexSearcher searcher = _searcher.get();+ return searcher.getIndexDir() == null ? dataDir + "index/" : searcher.getIndexDir();+ }}@@ -945,7 +947,8 @@ public final class SolrCore implements SolrInfoMBean {// The current searcher used to service queries.// Don't access this directly!!!! use getSearcher() to- // get it (and it will increment the ref count at the same time)+ // get it (and it will increment the ref count at the same time).+ // This reference is protected by searcherLock.private RefCounted<SolrIndexSearcher> _searcher;// All of the open searchers. Don't access this directly.