optimize refresh config. (#548)

Co-authored-by: Haotian Zhang <928016560@qq.com>
pull/551/head
lepdou 2 years ago committed by GitHub
parent 10171f6d5c
commit c5993c1483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,3 +21,4 @@
- [fix:set error handler named EnhancedRestTemplateReporter for RestTemplate](https://github.com/Tencent/spring-cloud-tencent/pull/543)
- [Fix issue: report the labels in request when report the result of invocation by Feign](https://github.com/Tencent/spring-cloud-tencent/pull/546)
- [optimizeadd switch for report call result and default false](https://github.com/Tencent/spring-cloud-tencent/pull/547)
- [Optimize: refresh @Value by reflect and only refresh affected ConfigurationProperties beans](https://github.com/Tencent/spring-cloud-tencent/pull/548)

@ -18,14 +18,14 @@
package com.tencent.cloud.polaris.config;
import com.tencent.cloud.polaris.config.adapter.AffectedConfigurationPropertiesRebinder;
import com.tencent.cloud.polaris.config.adapter.PolarisConfigPropertyRefresher;
import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager;
import com.tencent.cloud.polaris.config.adapter.PolarisReflectConfigPropertyAutoRefresher;
import com.tencent.cloud.polaris.config.adapter.PolarisRefreshContextConfigPropertyAutoRefresher;
import com.tencent.cloud.polaris.config.adapter.SmartConfigurationPropertiesRebinder;
import com.tencent.cloud.polaris.config.adapter.PolarisRefreshAffectedContextRefresher;
import com.tencent.cloud.polaris.config.adapter.PolarisRefreshEntireContextRefresher;
import com.tencent.cloud.polaris.config.annotation.PolarisConfigAnnotationProcessor;
import com.tencent.cloud.polaris.config.condition.ConditionalOnConfigReflectEnabled;
import com.tencent.cloud.polaris.config.condition.ConditionalOnNonDefaultBehavior;
import com.tencent.cloud.polaris.config.condition.ConditionalOnReflectRefreshType;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import com.tencent.cloud.polaris.config.listener.PolarisConfigChangeEventListener;
import com.tencent.cloud.polaris.config.spring.annotation.SpringValueProcessor;
@ -65,19 +65,17 @@ public class PolarisConfigAutoConfiguration {
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
@ConditionalOnNonDefaultBehavior
public ConfigurationPropertiesRebinder smartConfigurationPropertiesRebinder(
@ConditionalOnReflectRefreshType
public ConfigurationPropertiesRebinder affectedConfigurationPropertiesRebinder(
ConfigurationPropertiesBeans beans) {
// If using default behavior, not use SmartConfigurationPropertiesRebinder.
// Minimize te possibility of making mistakes.
return new SmartConfigurationPropertiesRebinder(beans);
return new AffectedConfigurationPropertiesRebinder(beans);
}
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
public PolarisConfigPropertyRefresher polarisRefreshContextPropertySourceAutoRefresher(PolarisConfigProperties polarisConfigProperties,
PolarisPropertySourceManager polarisPropertySourceManager, ContextRefresher contextRefresher) {
return new PolarisRefreshContextConfigPropertyAutoRefresher(polarisConfigProperties, polarisPropertySourceManager, contextRefresher);
PolarisPropertySourceManager polarisPropertySourceManager, ContextRefresher contextRefresher) {
return new PolarisRefreshEntireContextRefresher(polarisConfigProperties, polarisPropertySourceManager, contextRefresher);
}
@Configuration(proxyBeanMethods = false)
@ -104,7 +102,8 @@ public class PolarisConfigAutoConfiguration {
public PolarisConfigPropertyRefresher polarisReflectPropertySourceAutoRefresher(PolarisConfigProperties polarisConfigProperties,
PolarisPropertySourceManager polarisPropertySourceManager, SpringValueRegistry springValueRegistry,
PlaceholderHelper placeholderHelper) {
return new PolarisReflectConfigPropertyAutoRefresher(polarisConfigProperties, polarisPropertySourceManager, springValueRegistry, placeholderHelper);
return new PolarisRefreshAffectedContextRefresher(polarisConfigProperties, polarisPropertySourceManager,
springValueRegistry, placeholderHelper);
}
}
}

@ -18,10 +18,10 @@
package com.tencent.cloud.polaris.config;
import com.tencent.cloud.polaris.config.adapter.AffectedConfigurationPropertiesRebinder;
import com.tencent.cloud.polaris.config.adapter.PolarisConfigFileLocator;
import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager;
import com.tencent.cloud.polaris.config.adapter.SmartConfigurationPropertiesRebinder;
import com.tencent.cloud.polaris.config.condition.ConditionalOnNonDefaultBehavior;
import com.tencent.cloud.polaris.config.condition.ConditionalOnReflectRefreshType;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration;
@ -89,11 +89,9 @@ public class PolarisConfigBootstrapAutoConfiguration {
@Bean
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT)
@ConditionalOnNonDefaultBehavior
public ConfigurationPropertiesRebinder smartConfigurationPropertiesRebinder(
@ConditionalOnReflectRefreshType
public ConfigurationPropertiesRebinder affectedConfigurationPropertiesRebinder(
ConfigurationPropertiesBeans beans) {
// If using default behavior, not use SmartConfigurationPropertiesRebinder.
// Minimize te possibility of making mistakes.
return new SmartConfigurationPropertiesRebinder(beans);
return new AffectedConfigurationPropertiesRebinder(beans);
}
}

@ -0,0 +1,81 @@
/*
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
*/
package com.tencent.cloud.polaris.config.adapter;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.springframework.beans.BeansException;
import org.springframework.boot.context.properties.ConfigurationPropertiesBean;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.cloud.context.properties.ConfigurationPropertiesBeans;
import org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.CollectionUtils;
/**
* Optimize {@link ConfigurationPropertiesRebinder}, only rebuild affected beans.
* @author weihubeats 2022-7-10
*/
public class AffectedConfigurationPropertiesRebinder extends ConfigurationPropertiesRebinder {
private ApplicationContext applicationContext;
private Map<String, ConfigurationPropertiesBean> propertiesBeans = new HashMap<>();
public AffectedConfigurationPropertiesRebinder(ConfigurationPropertiesBeans beans) {
super(beans);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
super.setApplicationContext(applicationContext);
this.applicationContext = applicationContext;
propertiesBeans = ConfigurationPropertiesBean.getAll(applicationContext);
}
@Override
public void onApplicationEvent(EnvironmentChangeEvent event) {
if (this.applicationContext.equals(event.getSource())) {
rebindAffectedBeans(event);
}
}
private void rebindAffectedBeans(EnvironmentChangeEvent event) {
Set<String> changedKeys = event.getKeys();
if (CollectionUtils.isEmpty(changedKeys)) {
return;
}
propertiesBeans.forEach((name, bean) -> {
changedKeys.forEach(key -> {
String propertiesPrefix = Objects.requireNonNull(AnnotationUtils.getValue(bean.getAnnotation()))
.toString();
if (key.startsWith(propertiesPrefix)) {
rebind(name);
}
});
});
}
}

@ -82,7 +82,7 @@ public abstract class PolarisConfigPropertyAutoRefresher
.addChangeListener((ConfigKVFileChangeListener) configKVFileChangeEvent -> {
LOGGER.info(
"[SCT Config] received polaris config change event and will refresh spring context."
"[SCT Config] received polaris config change event and will refresh spring context."
+ " namespace = {}, group = {}, fileName = {}",
polarisPropertySource.getNamespace(),
polarisPropertySource.getGroup(),

@ -21,7 +21,6 @@ package com.tencent.cloud.polaris.config.adapter;
import java.util.Collection;
import java.util.Set;
import com.tencent.cloud.common.util.JacksonUtils;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import com.tencent.cloud.polaris.config.spring.property.PlaceholderHelper;
import com.tencent.cloud.polaris.config.spring.property.SpringValue;
@ -39,15 +38,15 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.lang.NonNull;
/**
* PolarisReflectConfigPropertyAutoRefresher to refresh config in reflect type
* we can use it by setting spring.cloud.polaris.config.refresh-type=reflect.
* 1. The refresh of @Value properties is implemented through reflection.
* 2. Implement @ConfigurationProperties bean property refresh via EnvironmentChangeEvent,
* while rebuilding only beans with property changes.
*
* @author lingxiao.wlx
*/
public class PolarisReflectConfigPropertyAutoRefresher extends PolarisConfigPropertyAutoRefresher
implements ApplicationContextAware {
public class PolarisRefreshAffectedContextRefresher extends PolarisConfigPropertyAutoRefresher implements ApplicationContextAware {
private static final Logger LOGGER = LoggerFactory.getLogger(PolarisReflectConfigPropertyAutoRefresher.class);
private static final Logger LOGGER = LoggerFactory.getLogger(PolarisRefreshAffectedContextRefresher.class);
private final SpringValueRegistry springValueRegistry;
@ -59,9 +58,9 @@ public class PolarisReflectConfigPropertyAutoRefresher extends PolarisConfigProp
private TypeConverter typeConverter;
public PolarisReflectConfigPropertyAutoRefresher(PolarisConfigProperties polarisConfigProperties,
PolarisPropertySourceManager polarisPropertySourceManager, SpringValueRegistry springValueRegistry,
PlaceholderHelper placeholderHelper) {
public PolarisRefreshAffectedContextRefresher(PolarisConfigProperties polarisConfigProperties,
PolarisPropertySourceManager polarisPropertySourceManager, SpringValueRegistry springValueRegistry,
PlaceholderHelper placeholderHelper) {
super(polarisConfigProperties, polarisPropertySourceManager);
this.springValueRegistry = springValueRegistry;
this.placeholderHelper = placeholderHelper;
@ -89,11 +88,11 @@ public class PolarisReflectConfigPropertyAutoRefresher extends PolarisConfigProp
Object value = resolvePropertyValue(springValue);
springValue.update(value);
LOGGER.info("Auto update polaris changed value successfully, new value: {}, {}", value,
LOGGER.info("[SCT Config] Auto update polaris changed value successfully, new value: {}, {}", value,
springValue);
}
catch (Throwable ex) {
LOGGER.error("Auto update polaris changed value failed, {}", springValue.toString(), ex);
LOGGER.error("[SCT Config] Auto update polaris changed value failed, {}", springValue.toString(), ex);
}
}
@ -115,16 +114,6 @@ public class PolarisReflectConfigPropertyAutoRefresher extends PolarisConfigProp
return value;
}
private Object parseJsonValue(String json, Class<?> targetType) {
try {
return JacksonUtils.json2JavaBean(json, targetType);
}
catch (Throwable ex) {
LOGGER.error("Parsing json '{}' to type {} failed!", json, targetType, ex);
throw ex;
}
}
@Override
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException {
this.context = (ConfigurableApplicationContext) applicationContext;

@ -25,17 +25,18 @@ import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import org.springframework.cloud.context.refresh.ContextRefresher;
/**
* PolarisRefreshContextConfigPropertyAutoRefresher refresh config by refreshContext.
* The default implement of Spring Cloud refreshes the entire Spring Context.
* The disadvantage is that the entire context is rebuilt, which has a large impact and low performance.
*
* @author lingxiao.wlx
*/
public class PolarisRefreshContextConfigPropertyAutoRefresher extends PolarisConfigPropertyAutoRefresher {
public class PolarisRefreshEntireContextRefresher extends PolarisConfigPropertyAutoRefresher {
private final ContextRefresher contextRefresher;
public PolarisRefreshContextConfigPropertyAutoRefresher(PolarisConfigProperties polarisConfigProperties,
PolarisPropertySourceManager polarisPropertySourceManager,
ContextRefresher contextRefresher) {
public PolarisRefreshEntireContextRefresher(PolarisConfigProperties polarisConfigProperties,
PolarisPropertySourceManager polarisPropertySourceManager,
ContextRefresher contextRefresher) {
super(polarisConfigProperties, polarisPropertySourceManager);
this.contextRefresher = contextRefresher;
}

@ -1,125 +0,0 @@
/*
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
*/
package com.tencent.cloud.polaris.config.adapter;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import com.tencent.cloud.polaris.config.enums.RefreshBehavior;
import org.springframework.beans.BeansException;
import org.springframework.boot.context.properties.ConfigurationPropertiesBean;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.cloud.context.properties.ConfigurationPropertiesBeans;
import org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.ReflectionUtils;
import static com.tencent.cloud.polaris.config.condition.NonDefaultBehaviorCondition.POLARIS_CONFIG_REFRESH_BEHAVIOR;
import static com.tencent.cloud.polaris.config.enums.RefreshBehavior.ALL_BEANS;
/**
* Extend {@link ConfigurationPropertiesRebinder}.
* <p>
* Spring team doesn't seem to support single {@link ConfigurationPropertiesBean} refresh.
* <p>
* SmartConfigurationPropertiesRebinder can refresh specific
* {@link ConfigurationPropertiesBean} base on the change keys.
* <p>
* <strong> NOTE: We still use Spring's default behavior (full refresh) as default
* behavior, This feature can be considered an advanced feature, it may not be as stable
* as the default behavior. </strong>
* <code><a href=https://github.com/alibaba/spring-cloud-alibaba/blob/2.2.x/spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/refresh/SmartConfigurationPropertiesRebinder.java>
* SmartConfigurationPropertiesRebinder</a></code>
*
* @author weihubeats 2022-7-10
*/
public class SmartConfigurationPropertiesRebinder extends ConfigurationPropertiesRebinder {
private static final String BEANS = "beans";
private Map<String, ConfigurationPropertiesBean> beanMap;
private ApplicationContext applicationContext;
private RefreshBehavior refreshBehavior;
public SmartConfigurationPropertiesRebinder(ConfigurationPropertiesBeans beans) {
super(beans);
fillBeanMap(beans);
}
@SuppressWarnings("unchecked")
private void fillBeanMap(ConfigurationPropertiesBeans beans) {
this.beanMap = new HashMap<>();
Field field = ReflectionUtils.findField(beans.getClass(), BEANS);
if (field != null) {
field.setAccessible(true);
this.beanMap.putAll((Map<String, ConfigurationPropertiesBean>) Optional
.ofNullable(ReflectionUtils.getField(field, beans))
.orElse(Collections.emptyMap()));
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
super.setApplicationContext(applicationContext);
this.applicationContext = applicationContext;
this.refreshBehavior = this.applicationContext.getEnvironment().getProperty(
POLARIS_CONFIG_REFRESH_BEHAVIOR, RefreshBehavior.class,
ALL_BEANS);
}
@Override
public void onApplicationEvent(EnvironmentChangeEvent event) {
if (this.applicationContext.equals(event.getSource())
// Backwards compatible
|| event.getKeys().equals(event.getSource())) {
switch (refreshBehavior) {
case SPECIFIC_BEAN:
rebindSpecificBean(event);
break;
case ALL_BEANS:
default:
rebind();
break;
}
}
}
private void rebindSpecificBean(EnvironmentChangeEvent event) {
Set<String> refreshedSet = new HashSet<>();
beanMap.forEach((name, bean) -> event.getKeys().forEach(changeKey -> {
String prefix = Objects.requireNonNull(AnnotationUtils.getValue(bean.getAnnotation())).toString();
// prevent multiple refresh one ConfigurationPropertiesBean.
if (changeKey.startsWith(prefix) && refreshedSet.add(name)) {
rebind(name);
}
}));
}
}

@ -34,7 +34,7 @@ import org.springframework.context.annotation.Conditional;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
@Documented
@Conditional(NonDefaultBehaviorCondition.class)
public @interface ConditionalOnNonDefaultBehavior {
@Conditional(ReflectRefreshTypeCondition.class)
public @interface ConditionalOnReflectRefreshType {
}

@ -18,7 +18,7 @@
package com.tencent.cloud.polaris.config.condition;
import com.tencent.cloud.polaris.config.enums.RefreshBehavior;
import com.tencent.cloud.polaris.config.enums.RefreshType;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
@ -26,30 +26,28 @@ import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Extend SpringBootCondition.
* The refresh type of reflect condition.
*
* @author weihubeats 2022-7-13
*/
public class NonDefaultBehaviorCondition extends SpringBootCondition {
public class ReflectRefreshTypeCondition extends SpringBootCondition {
/**
* refresh behavior config.
* the property key of refresh type.
*/
public static final String POLARIS_CONFIG_REFRESH_BEHAVIOR = "spring.cloud.polaris.config.refresh-behavior";
public static final String POLARIS_CONFIG_REFRESH_TYPE = "spring.cloud.polaris.config.refresh-type";
/**
* refresh behavior config default value.
*/
private static final RefreshBehavior DEFAULT_REFRESH_BEHAVIOR = RefreshBehavior.ALL_BEANS;
private static final RefreshType DEFAULT_REFRESH_TYPE = RefreshType.REFRESH_CONTEXT;
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
RefreshBehavior behavior = context.getEnvironment().getProperty(
POLARIS_CONFIG_REFRESH_BEHAVIOR, RefreshBehavior.class, DEFAULT_REFRESH_BEHAVIOR);
if (DEFAULT_REFRESH_BEHAVIOR == behavior) {
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
RefreshType refreshType = context.getEnvironment()
.getProperty(POLARIS_CONFIG_REFRESH_TYPE, RefreshType.class, DEFAULT_REFRESH_TYPE);
if (refreshType == DEFAULT_REFRESH_TYPE) {
return ConditionOutcome.noMatch("no matched");
}
return ConditionOutcome.match("matched");
}
}

@ -42,12 +42,6 @@
"description": "Whether to connect to a remote server, suitable for local development mode.",
"sourceType": "com.tencent.cloud.polaris.config.config.PolarisConfigProperties"
},
{
"name": "spring.cloud.polaris.config.refresh-behavior",
"type": "com.tencent.cloud.polaris.config.enums.RefreshBehavior",
"defaultValue": "all_beans",
"description": "ConfigurationPropertiesBean refresh behavior."
},
{
"name": "spring.cloud.polaris.config.refresh-type",
"type": "com.tencent.cloud.polaris.config.enums.RefreshType",

@ -47,7 +47,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* test for {@link PolarisReflectConfigPropertyAutoRefresher}.
* test for {@link PolarisRefreshAffectedContextRefresher}.
*
* @author lepdou 2022-06-11
*/
@ -70,7 +70,7 @@ public class PolarisPropertiesSourceAutoRefresherTest {
@Test
public void testConfigFileChanged() throws Exception {
PolarisReflectConfigPropertyAutoRefresher refresher = new PolarisReflectConfigPropertyAutoRefresher(polarisConfigProperties,
PolarisRefreshAffectedContextRefresher refresher = new PolarisRefreshAffectedContextRefresher(polarisConfigProperties,
polarisPropertySourceManager, springValueRegistry, placeholderHelper);
ConfigurableApplicationContext applicationContext = mock(ConfigurableApplicationContext.class);
ConfigurableListableBeanFactory beanFactory = mock(ConfigurableListableBeanFactory.class);

@ -21,8 +21,8 @@ package com.tencent.cloud.polaris.config.condition;
import com.tencent.cloud.polaris.config.PolarisConfigAutoConfiguration;
import com.tencent.cloud.polaris.config.PolarisConfigBootstrapAutoConfiguration;
import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager;
import com.tencent.cloud.polaris.config.adapter.PolarisReflectConfigPropertyAutoRefresher;
import com.tencent.cloud.polaris.config.adapter.PolarisRefreshContextConfigPropertyAutoRefresher;
import com.tencent.cloud.polaris.config.adapter.PolarisRefreshAffectedContextRefresher;
import com.tencent.cloud.polaris.config.adapter.PolarisRefreshEntireContextRefresher;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import com.tencent.cloud.polaris.config.enums.RefreshType;
import com.tencent.cloud.polaris.config.spring.annotation.SpringValueProcessor;
@ -32,6 +32,7 @@ import org.junit.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration;
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.cloud.context.refresh.ContextRefresher;
@ -50,6 +51,7 @@ public class ConditionalOnConfigReflectEnabledTest {
.withConfiguration(AutoConfigurations.of(PolarisConfigBootstrapAutoConfiguration.class))
.withConfiguration(AutoConfigurations.of(PolarisConfigAutoConfiguration.class))
.withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class))
.withConfiguration(AutoConfigurations.of(ConfigurationPropertiesRebinderAutoConfiguration.class))
.withPropertyValues("spring.application.name=" + "conditionalOnConfigReflectEnabledTest")
.withPropertyValues("server.port=" + 8080)
.withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081")
@ -59,7 +61,7 @@ public class ConditionalOnConfigReflectEnabledTest {
assertThat(context).hasSingleBean(PlaceholderHelper.class);
assertThat(context).hasSingleBean(SpringValueRegistry.class);
assertThat(context).hasSingleBean(SpringValueProcessor.class);
assertThat(context).hasSingleBean(PolarisReflectConfigPropertyAutoRefresher.class);
assertThat(context).hasSingleBean(PolarisRefreshAffectedContextRefresher.class);
});
}
@ -69,6 +71,7 @@ public class ConditionalOnConfigReflectEnabledTest {
.withConfiguration(AutoConfigurations.of(PolarisConfigBootstrapAutoConfiguration.class))
.withConfiguration(AutoConfigurations.of(PolarisConfigAutoConfiguration.class))
.withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class))
.withConfiguration(AutoConfigurations.of(ConfigurationPropertiesRebinderAutoConfiguration.class))
.withPropertyValues("spring.application.name=" + "conditionalOnConfigReflectEnabledTest")
.withPropertyValues("server.port=" + 8080)
.withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081")
@ -77,7 +80,7 @@ public class ConditionalOnConfigReflectEnabledTest {
assertThat(context).hasSingleBean(PolarisConfigProperties.class);
assertThat(context).hasSingleBean(PolarisPropertySourceManager.class);
assertThat(context).hasSingleBean(ContextRefresher.class);
assertThat(context).hasSingleBean(PolarisRefreshContextConfigPropertyAutoRefresher.class);
assertThat(context).hasSingleBean(PolarisRefreshEntireContextRefresher.class);
});
}
}

@ -12,7 +12,7 @@ spring:
groups:
- name: ${spring.application.name} # group name
files: [ "config/application.properties", "config/bootstrap.yml" ] # config/application.properties takes precedence over config/bootstrap.yml
refresh-behavior: specific_bean
refresh-type: reflect
management:
endpoints:
web:

Loading…
Cancel
Save