This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new 760efed4532 SOLR-13044: fix searcher/core close sequence (#815)
760efed4532 is described below

commit 760efed45321f197da86c353a51c5d48bc0a3a6e
Author: David Smiley <[email protected]>
AuthorDate: Fri Apr 22 16:35:33 2022 -0400

    SOLR-13044: fix searcher/core close sequence (#815)
---
 .../java/org/apache/solr/handler/IndexFetcher.java | 25 +++++++++++-----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java 
b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index 1b23b5b9dce..b3b01b583fa 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -1009,7 +1009,6 @@ public class IndexFetcher {
   }
 
   private void openNewSearcherAndUpdateCommitPoint() throws IOException {
-    RefCounted<SolrIndexSearcher> searcher = null;
     IndexCommit commitPoint;
     // must get the latest solrCore object because the one we have might be 
closed because of a
     // reload
@@ -1020,18 +1019,20 @@ public class IndexFetcher {
       }
       @SuppressWarnings("unchecked")
       Future<Void>[] waitSearcher = (Future<Void>[]) 
Array.newInstance(Future.class, 1);
-      searcher = core.getSearcher(true, true, waitSearcher, true);
-      if (waitSearcher[0] != null) {
-        try {
-          waitSearcher[0].get();
-        } catch (InterruptedException | ExecutionException e) {
-          SolrException.log(log, e);
+      RefCounted<SolrIndexSearcher> searcher = core.getSearcher(true, true, 
waitSearcher, true);
+      try {
+        if (waitSearcher[0] != null) {
+          try {
+            waitSearcher[0].get();
+          } catch (InterruptedException | ExecutionException e) {
+            SolrException.log(log, e);
+          }
+        }
+        commitPoint = searcher.get().getIndexReader().getIndexCommit();
+      } finally {
+        if (searcher != null) {
+          searcher.decref();
         }
-      }
-      commitPoint = searcher.get().getIndexReader().getIndexCommit();
-    } finally {
-      if (searcher != null) {
-        searcher.decref();
       }
     }
 

Reply via email to