Workaround for cache initialization failure discovered in #30120

Create Infinispan configuration in the main thread to have access to the
default option values.

Fixes #30130

Signed-off-by: Pedro Ruivo <pruivo@redhat.com>
This commit is contained in:
Pedro Ruivo 2024-06-04 12:35:32 +01:00 committed by GitHub
parent d1756564a7
commit 82beee607e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -73,12 +73,10 @@ public class CacheManagerFactory {
private static final Logger logger = Logger.getLogger(CacheManagerFactory.class); private static final Logger logger = Logger.getLogger(CacheManagerFactory.class);
private final String config;
private final CompletableFuture<DefaultCacheManager> cacheManagerFuture; private final CompletableFuture<DefaultCacheManager> cacheManagerFuture;
public CacheManagerFactory(String config) { public CacheManagerFactory(String config) {
this.config = config; this.cacheManagerFuture = startEmbeddedCacheManager(config);
this.cacheManagerFuture = CompletableFuture.supplyAsync(this::startEmbeddedCacheManager);
} }
public DefaultCacheManager getOrCreateEmbeddedCacheManager() { public DefaultCacheManager getOrCreateEmbeddedCacheManager() {
@ -107,7 +105,7 @@ public class CacheManagerFactory {
} }
} }
private DefaultCacheManager startEmbeddedCacheManager() { private CompletableFuture<DefaultCacheManager> startEmbeddedCacheManager(String config) {
ConfigurationBuilderHolder builder = new ParserRegistry().parse(config); ConfigurationBuilderHolder builder = new ParserRegistry().parse(config);
if (builder.getNamedConfigurationBuilders().entrySet().stream().anyMatch(c -> c.getValue().clustering().cacheMode().isClustered())) { if (builder.getNamedConfigurationBuilders().entrySet().stream().anyMatch(c -> c.getValue().clustering().cacheMode().isClustered())) {
@ -152,7 +150,8 @@ public class CacheManagerFactory {
} }
Marshalling.configure(builder.getGlobalConfigurationBuilder()); Marshalling.configure(builder.getGlobalConfigurationBuilder());
return new DefaultCacheManager(builder, isStartEagerly()); var start = isStartEagerly();
return CompletableFuture.supplyAsync(() -> new DefaultCacheManager(builder, start));
} }
private static boolean isRemoteTLSEnabled() { private static boolean isRemoteTLSEnabled() {