Merge branch '2.7.x'
Closes gh-32246
This commit is contained in:
@@ -52,6 +52,8 @@ class HazelcastServerConfiguration {
|
||||
|
||||
static final String CONFIG_SYSTEM_PROPERTY = "hazelcast.config";
|
||||
|
||||
static final String HAZELCAST_LOGGING_TYPE = "hazelcast.logging.type";
|
||||
|
||||
private static HazelcastInstance getHazelcastInstance(Config config) {
|
||||
if (StringUtils.hasText(config.getInstanceName())) {
|
||||
return Hazelcast.getOrCreateHazelcastInstance(config);
|
||||
@@ -123,6 +125,22 @@ class HazelcastServerConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(org.slf4j.Logger.class)
|
||||
static class HazelcastLoggingConfigCustomizerConfiguration {
|
||||
|
||||
@Bean
|
||||
@Order(0)
|
||||
HazelcastConfigCustomizer loggingHazelcastConfigCustomizer() {
|
||||
return (config) -> {
|
||||
if (!config.getProperties().containsKey(HAZELCAST_LOGGING_TYPE)) {
|
||||
config.setProperty(HAZELCAST_LOGGING_TYPE, "slf4j");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link HazelcastConfigResourceCondition} that checks if the
|
||||
* {@code spring.hazelcast.config} configuration key is defined.
|
||||
|
||||
@@ -206,6 +206,22 @@ class HazelcastAutoConfigurationServerTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoConfiguredConfigSetsHazelcastLoggingToSlf4j() {
|
||||
this.contextRunner.run((context) -> {
|
||||
Config config = context.getBean(HazelcastInstance.class).getConfig();
|
||||
assertThat(config.getProperty(HazelcastServerConfiguration.HAZELCAST_LOGGING_TYPE)).isEqualTo("slf4j");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoConfiguredConfigCanOverrideHazelcastLogging() {
|
||||
this.contextRunner.withUserConfiguration(HazelcastConfigWithJDKLogging.class).run((context) -> {
|
||||
Config config = context.getBean(HazelcastInstance.class).getConfig();
|
||||
assertThat(config.getProperty(HazelcastServerConfiguration.HAZELCAST_LOGGING_TYPE)).isEqualTo("jdk");
|
||||
});
|
||||
}
|
||||
|
||||
private static Config createTestConfig(String instanceName) {
|
||||
Config config = new Config(instanceName);
|
||||
JoinConfig join = config.getNetworkConfig().getJoin();
|
||||
@@ -236,6 +252,18 @@ class HazelcastAutoConfigurationServerTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class HazelcastConfigWithJDKLogging {
|
||||
|
||||
@Bean
|
||||
Config anotherHazelcastConfig() {
|
||||
Config config = new Config();
|
||||
config.setProperty(HazelcastServerConfiguration.HAZELCAST_LOGGING_TYPE, "jdk");
|
||||
return config;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SpringAware
|
||||
static class SpringAwareEntryProcessor<V> implements EntryProcessor<String, V, String> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user