diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java index fef81cc14417..f695e1bec041 100644 --- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java +++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java @@ -51,6 +51,7 @@ import com.codahale.metrics.Meter; import org.apache.hadoop.fs.FileSystem; import org.apache.lucene.util.BytesRef; +import org.apache.solr.common.AlreadyClosedException; import org.apache.solr.common.ParWork; import org.apache.solr.common.SolrDocumentBase; import org.apache.solr.common.SolrException; @@ -101,6 +102,8 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer { public static String TLOG_NAME="tlog"; public static String BUFFER_TLOG_NAME="buffer.tlog"; + private volatile boolean isClosed = false; + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private boolean debug = log.isDebugEnabled(); private boolean trace = log.isTraceEnabled(); @@ -485,6 +488,9 @@ public SolrMetricsContext getSolrMetricsContext() { * change the implementation of the transaction log. */ public TransactionLog newTransactionLog(File tlogFile, Collection globalStrings, boolean openExisting, byte[] buffer) { + if (isClosed) { + throw new AlreadyClosedException(); + } return new TransactionLog(tlogFile, globalStrings, openExisting); } @@ -1380,6 +1386,7 @@ public void close(boolean committed) { } public void close(boolean committed, boolean deleteOnClose) { + this.isClosed = true; recoveryExecutor.shutdown(); // no new tasks synchronized (this) {