Skip to content

Commit

Permalink
Merge pull request quarkusio#18618 from karesti/create-empty-infinispan
Browse files Browse the repository at this point in the history
Upgrades infinispan extension: don't create Remote Cache Manager without server list
  • Loading branch information
gastaldi authored Jul 16, 2021
2 parents c5ba24e + 326e161 commit 16dd69e
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.RemoteCounterManagerFactory;
import org.infinispan.client.hotrod.configuration.Configuration;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.impl.ConfigurationProperties;
import org.infinispan.client.hotrod.logging.Log;
Expand Down Expand Up @@ -61,10 +60,14 @@ private void initialize() {
return;
}

Configuration conf = builderFromProperties(properties).build();
cacheManager = new RemoteCacheManager(conf);

ConfigurationBuilder conf = builderFromProperties(properties);
if (conf.servers().isEmpty()) {
return;
}
// Build de cache manager if the server list is present
cacheManager = new RemoteCacheManager(conf.build());
InfinispanClientRuntimeConfig infinispanClientRuntimeConfig = this.infinispanClientRuntimeConfig.get();

if (infinispanClientRuntimeConfig.useSchemaRegistration.orElse(Boolean.TRUE)) {
RemoteCache<String, String> protobufMetadataCache = null;
Set<SerializationContextInitializer> initializers = (Set) properties.remove(PROTOBUF_INITIALIZERS);
Expand Down Expand Up @@ -282,16 +285,24 @@ public <K, V> RemoteCache<K, V> getRemoteCache(InjectionPoint injectionPoint, Re

final io.quarkus.infinispan.client.Remote remote = getRemoteAnnotation(annotationSet);

if (remote != null && !remote.value().isEmpty()) {
if (cacheManager != null && remote != null && !remote.value().isEmpty()) {
return cacheManager.getCache(remote.value());
}

return cacheManager.getCache();
if (cacheManager != null) {
return cacheManager.getCache();
}

return null;
}

@Produces
public CounterManager counterManager() {
return RemoteCounterManagerFactory.asCounterManager(remoteCacheManager());
RemoteCacheManager cacheManager = remoteCacheManager();
if (cacheManager == null) {
return null;
}
return RemoteCounterManagerFactory.asCounterManager(cacheManager);
}

@Produces
Expand Down

0 comments on commit 16dd69e

Please sign in to comment.