From 275f15b8d3951e49ab6d254f88ad06afb68871f3 Mon Sep 17 00:00:00 2001 From: lucas persson Date: Wed, 4 Jan 2023 16:31:00 +0100 Subject: [PATCH] Use hazelcast's Config.loadFromStream() To allow the private function Config.applyEnvAndSystemVariableOverrides() to override with environment variables See gh-33687 --- .../hazelcast/HazelcastServerConfiguration.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java index 4540145be7..fd0de8b4ad 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastServerConfiguration.java @@ -20,8 +20,6 @@ import java.io.IOException; import java.net.URL; import com.hazelcast.config.Config; -import com.hazelcast.config.XmlConfigBuilder; -import com.hazelcast.config.YamlConfigBuilder; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.spring.context.SpringManagedContext; @@ -78,7 +76,7 @@ class HazelcastServerConfiguration { private Config loadConfig(Resource configLocation) throws IOException { URL configUrl = configLocation.getURL(); - Config config = loadConfig(configUrl); + Config config = Config.loadFromStream(configUrl.openStream()); if (ResourceUtils.isFileURL(configUrl)) { config.setConfigurationFile(configLocation.getFile()); } @@ -88,14 +86,6 @@ class HazelcastServerConfiguration { return config; } - private static Config loadConfig(URL configUrl) throws IOException { - String configFileName = configUrl.getPath(); - if (configFileName.endsWith(".yaml") || configFileName.endsWith(".yml")) { - return new YamlConfigBuilder(configUrl).build(); - } - return new XmlConfigBuilder(configUrl).build(); - } - } @Configuration(proxyBeanMethods = false)