From 9d8a62ce962c34730a0d3ad17bcf37b35d78beb8 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Sun, 29 Jan 2012 03:41:37 +0000 Subject: [PATCH] if there is an exception when closing the writer, log it and keep closing git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1237200 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/update/DefaultSolrCoreState.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java index 06726a8e795..dc1afbeb7e6 100644 --- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java +++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java @@ -21,11 +21,15 @@ import java.io.IOException; import org.apache.lucene.index.IndexWriter; import org.apache.solr.cloud.RecoveryStrategy; +import org.apache.solr.common.SolrException; import org.apache.solr.core.DirectoryFactory; import org.apache.solr.core.SolrCore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class DefaultSolrCoreState extends SolrCoreState { - + public static Logger log = LoggerFactory.getLogger(DefaultSolrCoreState.class); + private final Object recoveryLock = new Object(); private int refCnt = 1; private SolrIndexWriter indexWriter = null; @@ -62,10 +66,14 @@ public final class DefaultSolrCoreState extends SolrCoreState { synchronized (this) { refCnt--; if (refCnt == 0) { - if (closer != null) { - closer.closeWriter(indexWriter); - } else if (indexWriter != null) { - indexWriter.close(); + try { + if (closer != null) { + closer.closeWriter(indexWriter); + } else if (indexWriter != null) { + indexWriter.close(); + } + } catch (Throwable t) { + SolrException.log(log, t); } directoryFactory.close(); closed = true;