From bc6a8d9fff38c1fa303626d8169ea0229be8ce18 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Tue, 18 Aug 2015 14:04:06 +0000 Subject: [PATCH] SOLR-7935:fix race that can cause a NPE in openNewSearcher called from an update concurrent with a core reload git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1696417 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ solr/core/src/java/org/apache/solr/core/SolrCore.java | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 071f8e37eda..581365ede3b 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -139,6 +139,9 @@ Bug Fixes * SOLR-7920: Resolve XSS issue in Admin UI Schema Browser (David Chiu via Upayavira) +* SOLR-7935: Fix very rare race condition that can cause an update to fail + via NullPointerException during a core reload. (yonik) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index efa28b06fda..80707cb21ad 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -1584,8 +1584,8 @@ public final class SolrCore implements SolrInfoMBean, Closeable { // SolrCore.verbose("start reopen from",previousSearcher,"writer=",writer); - RefCounted writer = getUpdateHandler().getSolrCoreState() - .getIndexWriter(null); + RefCounted writer = getSolrCoreState().getIndexWriter(null); + try { if (writer != null) { // if in NRT mode, open from the writer @@ -1639,7 +1639,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable { tmp = new SolrIndexSearcher(this, newIndexDir, getLatestSchema(), (realtime ? "realtime":"main"), newReader, true, !realtime, true, directoryFactory); } else { - RefCounted writer = getUpdateHandler().getSolrCoreState().getIndexWriter(this); + RefCounted writer = getSolrCoreState().getIndexWriter(this); DirectoryReader newReader = null; try { newReader = indexReaderFactory.newReader(writer.get(), this);