Skip to content

Commit

Permalink
Release the Config from the TCCL when setting the Quarkus config
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Jan 29, 2025
1 parent 8d65dcf commit c0af390
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.runtime.configuration;

import org.eclipse.microprofile.config.spi.ConfigProviderResolver;

import io.quarkus.runtime.LaunchMode;
import io.smallrye.config.SmallRyeConfig;
import io.smallrye.config.SmallRyeConfigFactory;
Expand All @@ -25,7 +23,8 @@ public SmallRyeConfig getConfigFor(final SmallRyeConfigProviderResolver configPr
}

public static void setConfig(SmallRyeConfig config) {
ConfigProviderResolver configProviderResolver = ConfigProviderResolver.instance();
SmallRyeConfigProviderResolver configProviderResolver = (SmallRyeConfigProviderResolver) SmallRyeConfigProviderResolver
.instance();
// Uninstall previous config
if (QuarkusConfigFactory.config != null) {
configProviderResolver.releaseConfig(QuarkusConfigFactory.config);
Expand All @@ -34,9 +33,8 @@ public static void setConfig(SmallRyeConfig config) {
// Install new config
if (config != null) {
QuarkusConfigFactory.config = config;
// Register the new config for the TCCL,
// just in case the TCCL was using a different config
// than the one we uninstalled above.
// Someone may have called ConfigProvider.getConfig which automatically registers a Config in the TCCL
configProviderResolver.releaseConfig(Thread.currentThread().getContextClassLoader());
configProviderResolver.registerConfig(config, Thread.currentThread().getContextClassLoader());
}
}
Expand Down

0 comments on commit c0af390

Please sign in to comment.