You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2023/05/18 21:35:04 UTC
[solr] branch main updated: SOLR-16801: Reset the thread's contextClassloader after loading the CoreContainer (#1645)
This is an automated email from the ASF dual-hosted git repository.
houston 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 0a6a114319c SOLR-16801: Reset the thread's contextClassloader after loading the CoreContainer (#1645)
0a6a114319c is described below
commit 0a6a114319cbc2fcda1e36bbcb157e1841555884
Author: Thomas Wöckinger <th...@users.noreply.github.com>
AuthorDate: Thu May 18 23:34:58 2023 +0200
SOLR-16801: Reset the thread's contextClassloader after loading the CoreContainer (#1645)
Co-authored-by: Thomas Wöckinger <tw...@silbergrau.com>
Co-authored-by: Houston Putman <ho...@apache.org>
---
solr/CHANGES.txt | 2 ++
.../src/java/org/apache/solr/core/CoreContainer.java | 16 +++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1802555d81e..a33bfd8523a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -185,6 +185,8 @@ Bug Fixes
* SOLR-16765: bin/solr export tool limit property was off by 1. Now limit results exported to the exact number. (Eric Pugh)
+* SOLR-16801: Reset the thread's contextClassloader after loading the CoreContainer (Thomas Wöckinger, Houston Putman)
+
Dependency Upgrades
---------------------
* PR#1494: Upgrade forbiddenapis to 3.5 (Uwe Schindler)
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index a42c44aa878..b1c92abd48f 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -745,12 +745,22 @@ public class CoreContainer {
reason =
"Set the thread contextClassLoader for all 3rd party dependencies that we cannot control")
public void load() {
+ final ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ // Set the thread's contextClassLoader for any plugins that are loaded via Modules or Packages
+ // and have dependencies that use the thread's contextClassLoader
+ Thread.currentThread().setContextClassLoader(loader.getClassLoader());
+ loadInternal();
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalContextClassLoader);
+ }
+ }
+
+ /** Load the cores defined for this CoreContainer */
+ private void loadInternal() {
if (log.isDebugEnabled()) {
log.debug("Loading cores into CoreContainer [instanceDir={}]", getSolrHome());
}
- // Set the thread's contextClassLoader for any plugins that are loaded via Modules or Packages
- Thread.currentThread().setContextClassLoader(loader.getClassLoader());
-
logging = LogWatcher.newRegisteredLogWatcher(cfg.getLogWatcherConfig(), loader);
ClusterEventProducerFactory clusterEventProducerFactory = new ClusterEventProducerFactory(this);