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.lucene.index.IndexWriter;
import org.apache.solr.cloud.RecoveryStrategy; import org.apache.solr.cloud.RecoveryStrategy;
import org.apache.solr.common.SolrException;
import org.apache.solr.core.DirectoryFactory; import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class DefaultSolrCoreState extends SolrCoreState { public final class DefaultSolrCoreState extends SolrCoreState {
public static Logger log = LoggerFactory.getLogger(DefaultSolrCoreState.class);
private final Object recoveryLock = new Object(); private final Object recoveryLock = new Object();
private int refCnt = 1; private int refCnt = 1;
@ -62,10 +66,14 @@ public final class DefaultSolrCoreState extends SolrCoreState {
synchronized (this) { synchronized (this) {
refCnt--; refCnt--;
if (refCnt == 0) { if (refCnt == 0) {
if (closer != null) { try {
closer.closeWriter(indexWriter); if (closer != null) {
} else if (indexWriter != null) { closer.closeWriter(indexWriter);
indexWriter.close(); } else if (indexWriter != null) {
indexWriter.close();
}
} catch (Throwable t) {
SolrException.log(log, t);
} }
directoryFactory.close(); directoryFactory.close();
closed = true; closed = true;