Skip to content

Commit

Permalink
SOLR-16801: Reset the thread's contextClassloader after loading the C…
Browse files Browse the repository at this point in the history
…oreContainer (#1645)

Co-authored-by: Thomas Wöckinger <two@silbergrau.com>
Co-authored-by: Houston Putman <houston@apache.org>
(cherry picked from commit 0a6a114)
  • Loading branch information
thomaswoeckinger authored and HoustonPutman committed May 18, 2023
1 parent 717f3da commit f7867ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,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)
Expand Down
16 changes: 13 additions & 3 deletions solr/core/src/java/org/apache/solr/core/CoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -746,12 +746,22 @@ private void registerV2ApiIfEnabled(Class<? extends JerseyResource> clazz) {
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);
Expand Down

0 comments on commit f7867ec

Please sign in to comment.