This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 703782d SOLR-14686: fix MDC log clear in SolrCore.close (#583)
703782d is described below
commit 703782d1a1f63e0efa9377dad839c0913c880d37
Author: David Smiley <[email protected]>
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 [email protected]", 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 [email protected]", 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);
}