You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2022/02/03 20:06:33 UTC
[solr] branch branch_9_0 updated: SOLR-14686: fix MDC log clear in SolrCore.close (#583)
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_9_0
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9_0 by this push:
new 8b4fb64 SOLR-14686: fix MDC log clear in SolrCore.close (#583)
8b4fb64 is described below
commit 8b4fb6467ddd34a8c4bfec6c634ec815e1a1ca59
Author: David Smiley <ds...@apache.org>
AuthorDate: Wed Feb 2 16:22:46 2022 -0500
SOLR-14686: fix MDC log clear in SolrCore.close (#583)
this is a fix-up of previous commit for this issue
---
.../src/java/org/apache/solr/core/SolrCore.java | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index d3604a2..dc3887d 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1573,13 +1573,20 @@ public final class SolrCore implements SolrInfoBean, Closeable {
*/
@Override
public void close() {
- int count = refCount.decrementAndGet();
- if (count > 0) return; // close is called often, and only actually closes if nothing is using it.
- if (count < 0) {
- log.error("Too many close [count:{}] on {}. Please report this exception to users@solr.apache.org", count, this);
- assert false : "Too many closes on SolrCore";
- return;
+ try {
+ int count = refCount.decrementAndGet();
+ if (count < 0) {
+ log.error("Too many close [count:{}] on {}. Please report this exception to users@solr.apache.org", count, this);
+ assert false : "Too many closes on SolrCore";
+ } else if (count == 0) {
+ doClose();
+ }
+ } finally {
+ MDCLoggingContext.clear(); // balance out from SolrCore open with close
}
+ }
+
+ private void doClose() {
log.info("CLOSING SolrCore {}", this);
ExecutorUtil.shutdownAndAwaitTermination(coreAsyncTaskExecutor);
@@ -1720,8 +1727,6 @@ public final class SolrCore implements SolrInfoBean, Closeable {
}
}
- MDCLoggingContext.clear(); // balance out open with close
-
assert ObjectReleaseTracker.release(this);
}