Skip to content

Apache Lucene open-source search software

SOLR-12412: release IndexWriter after getting tragic exception

Cao Manh Datcd08c7ef1361
diff --git a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
index 64f6bc6b76b..665db776913 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
@@ -197,6 +197,10 @@ public abstract class SolrCoreState {
public Throwable getTragicException() throws IOException {
RefCounted<IndexWriter> ref = getIndexWriter(null);
if (ref == null) return null;
- return ref.get().getTragicException();
+ try {
+ return ref.get().getTragicException();
+ } finally {
+ ref.decref();
+ }
}
}