Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16801: Reset the thread's contextClassloader after loading the CoreContainer (#1645)

Thomas Wöckinger0a6a114319cb
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);