Skip to content

Commit

Permalink
SOLR-16801: Set previous context class loader after loading plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Wöckinger committed May 16, 2023
1 parent c0a84de commit a1dadef
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions solr/core/src/java/org/apache/solr/core/CoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,16 @@ private synchronized void initializeAuthenticationPlugin(
new Object[] {this}));
}
if (authenticationPlugin != null) {
authenticationPlugin.plugin.init(authenticationConfig);
setupHttpClientForAuthPlugin(authenticationPlugin.plugin);
authenticationPlugin.plugin.initializeMetrics(solrMetricsContext, "/authentication");
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
// Set the thread's contextClassLoader for any plugins that are loaded via Modules or Packages
Thread.currentThread().setContextClassLoader(loader.getClassLoader());
authenticationPlugin.plugin.init(authenticationConfig);
setupHttpClientForAuthPlugin(authenticationPlugin.plugin);
authenticationPlugin.plugin.initializeMetrics(solrMetricsContext, "/authentication");
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
this.authenticationPlugin = authenticationPlugin;
try {
Expand Down Expand Up @@ -749,9 +756,6 @@ public void load() {
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 a1dadef

Please sign in to comment.