mirror of
https://github.com/keycloak/keycloak.git
synced 2026-02-18 18:37:54 -05:00
Remove ConfigurationBuilderHolder field from DefaultCacheEmbeddedConfigProviderFactory
Closes #46138 Signed-off-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com> Co-authored-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com>
This commit is contained in:
parent
67bbdf3dd2
commit
dd7302a3af
2 changed files with 16 additions and 54 deletions
|
|
@ -68,7 +68,7 @@ import static org.keycloak.spi.infinispan.impl.embedded.JGroupsConfigurator.crea
|
|||
* They have access to the {@link ConfigurationBuilderHolder}, and they can modify it as needed for their custom
|
||||
* providers.
|
||||
*/
|
||||
public class DefaultCacheEmbeddedConfigProviderFactory implements CacheEmbeddedConfigProviderFactory, CacheEmbeddedConfigProvider {
|
||||
public class DefaultCacheEmbeddedConfigProviderFactory implements CacheEmbeddedConfigProviderFactory {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
|
@ -85,13 +85,17 @@ public class DefaultCacheEmbeddedConfigProviderFactory implements CacheEmbeddedC
|
|||
public static final String MACHINE_NAME = "machineName";
|
||||
public static final String RACK_NAME = "rackName";
|
||||
|
||||
private volatile ConfigurationBuilderHolder builderHolder;
|
||||
private volatile Config.Scope keycloakConfig;
|
||||
|
||||
@Override
|
||||
public CacheEmbeddedConfigProvider create(KeycloakSession session) {
|
||||
lazyInit(session.getKeycloakSessionFactory());
|
||||
return this;
|
||||
return () -> {
|
||||
try {
|
||||
return createConfiguration(session.getKeycloakSessionFactory());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -101,12 +105,6 @@ public class DefaultCacheEmbeddedConfigProviderFactory implements CacheEmbeddedC
|
|||
|
||||
@Override
|
||||
public void postInit(KeycloakSessionFactory factory) {
|
||||
lazyInit(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationBuilderHolder configuration() {
|
||||
return builderHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -143,22 +141,6 @@ public class DefaultCacheEmbeddedConfigProviderFactory implements CacheEmbeddedC
|
|||
return Set.of(JGroupsCertificateProvider.class);
|
||||
}
|
||||
|
||||
private void lazyInit(KeycloakSessionFactory factory) {
|
||||
if (builderHolder != null) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (builderHolder != null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
builderHolder = createConfiguration(factory);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ConfigurationBuilderHolder createConfiguration(KeycloakSessionFactory factory) throws IOException {
|
||||
var holder = parseConfiguration(keycloakConfig, factory);
|
||||
if (InfinispanUtils.isRemoteInfinispan()) {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ import org.keycloak.spi.infinispan.impl.embedded.CacheConfigurator;
|
|||
|
||||
import org.infinispan.client.hotrod.configuration.AuthenticationConfigurationBuilder;
|
||||
import org.infinispan.client.hotrod.configuration.ClientIntelligence;
|
||||
import org.infinispan.client.hotrod.configuration.Configuration;
|
||||
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
|
||||
import org.infinispan.client.hotrod.configuration.ExhaustedAction;
|
||||
import org.infinispan.client.hotrod.impl.ConfigurationProperties;
|
||||
|
|
@ -62,7 +61,7 @@ import static org.wildfly.security.sasl.util.SaslMechanismInformation.Names.SCRA
|
|||
* <p>
|
||||
* It is used when an external Infinispan cluster is enabled.
|
||||
*/
|
||||
public class DefaultCacheRemoteConfigProviderFactory implements CacheRemoteConfigProviderFactory, CacheRemoteConfigProvider, EnvironmentDependentProviderFactory {
|
||||
public class DefaultCacheRemoteConfigProviderFactory implements CacheRemoteConfigProviderFactory, EnvironmentDependentProviderFactory {
|
||||
|
||||
public static final String PROVIDER_ID = "default";
|
||||
private static final Logger logger = Logger.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
|
@ -88,7 +87,6 @@ public class DefaultCacheRemoteConfigProviderFactory implements CacheRemoteConfi
|
|||
private static final String CONNECTION_POOL_EXHAUSTED_ACTION_DEFAULT = ExhaustedAction.CREATE_NEW.name();
|
||||
private static final String SASL_MECHANISM_DEFAULT = SCRAM_SHA_512;
|
||||
|
||||
private volatile Configuration remoteConfiguration;
|
||||
private volatile Config.Scope keycloakConfiguration;
|
||||
|
||||
@Override
|
||||
|
|
@ -98,8 +96,13 @@ public class DefaultCacheRemoteConfigProviderFactory implements CacheRemoteConfi
|
|||
|
||||
@Override
|
||||
public CacheRemoteConfigProvider create(KeycloakSession session) {
|
||||
lazyInit();
|
||||
return this;
|
||||
return () -> {
|
||||
try {
|
||||
return Optional.of(createConfigurationBuilder().build());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -109,13 +112,6 @@ public class DefaultCacheRemoteConfigProviderFactory implements CacheRemoteConfi
|
|||
|
||||
@Override
|
||||
public void postInit(KeycloakSessionFactory factory) {
|
||||
lazyInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Configuration> configuration() {
|
||||
assert remoteConfiguration != null;
|
||||
return Optional.of(remoteConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -168,22 +164,6 @@ public class DefaultCacheRemoteConfigProviderFactory implements CacheRemoteConfi
|
|||
return builder;
|
||||
}
|
||||
|
||||
private void lazyInit() {
|
||||
if (remoteConfiguration != null) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (remoteConfiguration != null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
remoteConfiguration = createConfigurationBuilder().build();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadProperties(ConfigurationBuilder builder) throws IOException {
|
||||
var path = keycloakConfiguration.get(PROPERTIES_FILE);
|
||||
if (path == null) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue