Code review comment: @Sanne the kube use case is only valid for demos IMO, and even then providing a cache cr is a more production real use case than creating it from the properties, but for simplicity is clearly something easy to be done. I will remove the file and let URI and pasted configuration as it is

Code before review:
private ConfigurationBuilder builderFromProperties(Properties properties) {
ConfigurationBuilder builder = new ConfigurationBuilder();
Object marshallerInstance = properties.remove(ConfigurationProperties.MARSHALLER);
if (marshallerInstance != null) {
if (marshallerInstance instanceof ProtoStreamMarshaller) {
handleProtoStreamMarshaller((ProtoStreamMarshaller) marshallerInstance, properties, beanManager);
}
builder.marshaller((Marshaller) marshallerInstance);
}
InfinispanClientRuntimeConfig infinispanClientRuntimeConfig = this.infinispanClientRuntimeConfig.get();
if (infinispanClientRuntimeConfig.serverList.isPresent()) {
properties.put(ConfigurationProperties.SERVER_LIST, infinispanClientRuntimeConfig.serverList.get());
}
if (infinispanClientRuntimeConfig.clientIntelligence.isPresent()) {
properties.put(ConfigurationProperties.CLIENT_INTELLIGENCE, infinispanClientRuntimeConfig.clientIntelligence.get());
}
if (infinispanClientRuntimeConfig.useAuth.isPresent()) {
properties.put(ConfigurationProperties.USE_AUTH, infinispanClientRuntimeConfig.useAuth.get());
}
if (infinispanClientRuntimeConfig.authUsername.isPresent()) {
properties.put(ConfigurationProperties.AUTH_USERNAME, infinispanClientRuntimeConfig.authUsername.get());
}
if (infinispanClientRuntimeConfig.authPassword.isPresent()) {
properties.put(ConfigurationProperties.AUTH_PASSWORD, infinispanClientRuntimeConfig.authPassword.get());
}
if (infinispanClientRuntimeConfig.authRealm.isPresent()) {
properties.put(ConfigurationProperties.AUTH_REALM, infinispanClientRuntimeConfig.authRealm.get());
}
if (infinispanClientRuntimeConfig.authServerName.isPresent()) {
properties.put(ConfigurationProperties.AUTH_SERVER_NAME, infinispanClientRuntimeConfig.authServerName.get());
}
if (infinispanClientRuntimeConfig.authClientSubject.isPresent()) {
properties.put(ConfigurationProperties.AUTH_CLIENT_SUBJECT, infinispanClientRuntimeConfig.authClientSubject.get());
}
if (infinispanClientRuntimeConfig.authCallbackHandler.isPresent()) {
properties.put(ConfigurationProperties.AUTH_CALLBACK_HANDLER,
infinispanClientRuntimeConfig.authCallbackHandler.get());
}
if (infinispanClientRuntimeConfig.saslMechanism.isPresent()) {
properties.put(ConfigurationProperties.SASL_MECHANISM, infinispanClientRuntimeConfig.saslMechanism.get());
}
if (infinispanClientRuntimeConfig.trustStore.isPresent()) {
properties.put(ConfigurationProperties.TRUST_STORE_FILE_NAME, infinispanClientRuntimeConfig.trustStore.get());
}
if (infinispanClientRuntimeConfig.trustStorePassword.isPresent()) {
properties.put(ConfigurationProperties.TRUST_STORE_PASSWORD,
infinispanClientRuntimeConfig.trustStorePassword.get());
}
if (infinispanClientRuntimeConfig.trustStoreType.isPresent()) {
properties.put(ConfigurationProperties.TRUST_STORE_TYPE, infinispanClientRuntimeConfig.trustStoreType.get());
}
builder.withProperties(properties);
for (Map.Entry<String, InfinispanClientRuntimeConfig.RemoteCacheConfig> cache : infinispanClientRuntimeConfig.cache
.entrySet()) {
String cacheName = cache.getKey();
InfinispanClientRuntimeConfig.RemoteCacheConfig remoteCacheConfig = cache.getValue();
if (remoteCacheConfig.configurationUri.isPresent()) {
URL resource = InfinispanClientProducer.class.getClassLoader()
.getResource(remoteCacheConfig.configurationUri.get());
try {
builder.remoteCache(cacheName).configurationURI(resource.toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
} else if (remoteCacheConfig.configurationFile.isPresent()) {
try {
String content = getContents(InfinispanClientProducer.class.getClassLoader()
.getResourceAsStream(remoteCacheConfig.configurationFile.get()));
builder.remoteCache(cacheName).configuration(content);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (remoteCacheConfig.configuration.isPresent()) {
builder.remoteCache(cacheName).configuration(remoteCacheConfig.configuration.get());
}
if (remoteCacheConfig.nearCacheMaxEntries.isPresent()) {
builder.remoteCache(cacheName).nearCacheMaxEntries(remoteCacheConfig.nearCacheMaxEntries.get());
}
if (remoteCacheConfig.nearCacheMode.isPresent()) {
builder.remoteCache(cacheName).nearCacheMode(remoteCacheConfig.nearCacheMode.get());
}
if (remoteCacheConfig.nearCacheUseBloomFilter.isPresent()) {
builder.remoteCache(cacheName).nearCacheUseBloomFilter(remoteCacheConfig.nearCacheUseBloomFilter.get());
}
}
return builder;
}

Line under review: InfinispanClientRuntimeConfig.RemoteCacheConfig remoteCacheConfig = cache.getValue();

Code after addressing the review:
private ConfigurationBuilder builderFromProperties(Properties properties) {
ConfigurationBuilder builder = new ConfigurationBuilder();
Object marshallerInstance = properties.remove(ConfigurationProperties.MARSHALLER);
if (marshallerInstance != null) {
if (marshallerInstance instanceof ProtoStreamMarshaller) {
handleProtoStreamMarshaller((ProtoStreamMarshaller) marshallerInstance, properties, beanManager);
}
builder.marshaller((Marshaller) marshallerInstance);
}
InfinispanClientRuntimeConfig infinispanClientRuntimeConfig = this.infinispanClientRuntimeConfig.get();
if (infinispanClientRuntimeConfig.serverList.isPresent()) {
properties.put(ConfigurationProperties.SERVER_LIST, infinispanClientRuntimeConfig.serverList.get());
}
if (infinispanClientRuntimeConfig.clientIntelligence.isPresent()) {
properties.put(ConfigurationProperties.CLIENT_INTELLIGENCE, infinispanClientRuntimeConfig.clientIntelligence.get());
}
if (infinispanClientRuntimeConfig.useAuth.isPresent()) {
properties.put(ConfigurationProperties.USE_AUTH, infinispanClientRuntimeConfig.useAuth.get());
}
if (infinispanClientRuntimeConfig.authUsername.isPresent()) {
properties.put(ConfigurationProperties.AUTH_USERNAME, infinispanClientRuntimeConfig.authUsername.get());
}
if (infinispanClientRuntimeConfig.authPassword.isPresent()) {
properties.put(ConfigurationProperties.AUTH_PASSWORD, infinispanClientRuntimeConfig.authPassword.get());
}
if (infinispanClientRuntimeConfig.authRealm.isPresent()) {
properties.put(ConfigurationProperties.AUTH_REALM, infinispanClientRuntimeConfig.authRealm.get());
}
if (infinispanClientRuntimeConfig.authServerName.isPresent()) {
properties.put(ConfigurationProperties.AUTH_SERVER_NAME, infinispanClientRuntimeConfig.authServerName.get());
}
if (infinispanClientRuntimeConfig.authClientSubject.isPresent()) {
properties.put(ConfigurationProperties.AUTH_CLIENT_SUBJECT, infinispanClientRuntimeConfig.authClientSubject.get());
}
if (infinispanClientRuntimeConfig.authCallbackHandler.isPresent()) {
properties.put(ConfigurationProperties.AUTH_CALLBACK_HANDLER,
infinispanClientRuntimeConfig.authCallbackHandler.get());
}
if (infinispanClientRuntimeConfig.saslMechanism.isPresent()) {
properties.put(ConfigurationProperties.SASL_MECHANISM, infinispanClientRuntimeConfig.saslMechanism.get());
}
if (infinispanClientRuntimeConfig.trustStore.isPresent()) {
properties.put(ConfigurationProperties.TRUST_STORE_FILE_NAME, infinispanClientRuntimeConfig.trustStore.get());
}
if (infinispanClientRuntimeConfig.trustStorePassword.isPresent()) {
properties.put(ConfigurationProperties.TRUST_STORE_PASSWORD,
infinispanClientRuntimeConfig.trustStorePassword.get());
}
if (infinispanClientRuntimeConfig.trustStoreType.isPresent()) {
properties.put(ConfigurationProperties.TRUST_STORE_TYPE, infinispanClientRuntimeConfig.trustStoreType.get());
}
builder.withProperties(properties);
for (Map.Entry<String, InfinispanClientRuntimeConfig.RemoteCacheConfig> cache : infinispanClientRuntimeConfig.cache
.entrySet()) {
String cacheName = cache.getKey();
InfinispanClientRuntimeConfig.RemoteCacheConfig remoteCacheConfig = cache.getValue();
if (remoteCacheConfig.configurationUri.isPresent()) {
URL configFile = InfinispanClientProducer.class.getClassLoader()
.getResource(remoteCacheConfig.configurationUri.get());
try {
builder.remoteCache(cacheName).configurationURI(configFile.toURI());
} catch (Exception e) {
throw new RuntimeException(e);
}
} else if (remoteCacheConfig.configuration.isPresent()) {
builder.remoteCache(cacheName).configuration(remoteCacheConfig.configuration.get());
}
if (remoteCacheConfig.nearCacheMaxEntries.isPresent()) {
builder.remoteCache(cacheName).nearCacheMaxEntries(remoteCacheConfig.nearCacheMaxEntries.get());
}
if (remoteCacheConfig.nearCacheMode.isPresent()) {
builder.remoteCache(cacheName).nearCacheMode(remoteCacheConfig.nearCacheMode.get());
}
if (remoteCacheConfig.nearCacheUseBloomFilter.isPresent()) {
builder.remoteCache(cacheName).nearCacheUseBloomFilter(remoteCacheConfig.nearCacheUseBloomFilter.get());
}
}
return builder;
}