Skip to content

Commit

Permalink
Have logic still surround all of load
Browse files Browse the repository at this point in the history
  • Loading branch information
HoustonPutman authored and Thomas Wöckinger committed May 18, 2023
1 parent 702a58f commit 7ed55b9
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions solr/core/src/java/org/apache/solr/core/CoreContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,16 +560,9 @@ private synchronized void initializeAuthenticationPlugin(
new Object[] {this}));
}
if (authenticationPlugin != null) {
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);
}
authenticationPlugin.plugin.init(authenticationConfig);
setupHttpClientForAuthPlugin(authenticationPlugin.plugin);
authenticationPlugin.plugin.initializeMetrics(solrMetricsContext, "/authentication");
}
this.authenticationPlugin = authenticationPlugin;
try {
Expand Down Expand Up @@ -752,6 +745,19 @@ 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());
}
Expand Down

0 comments on commit 7ed55b9

Please sign in to comment.