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
This commit is contained in:
Mark Robert Miller 2012-01-29 03:41:37 +00:00
parent 210301b424
commit 9d8a62ce96
1 changed files with 13 additions and 5 deletions

View File

@ -21,10 +21,14 @@ 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;
@ -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;