diff --git a/CHANGELOG.md b/CHANGELOG.md index 3753c5106..3255ea955 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,4 +26,6 @@ - fix:fix feign report -1 port bug. - fix:upgrade spring version. - fix:Update README-zh.md -- feature: support Polaris configuration center extension plugin interface and support dynamic modification of log levels. \ No newline at end of file +- feature: support Polaris configuration center extension plugin interface and support dynamic modification of log + levels. +- fix:fix system env variable read bug. diff --git a/pom.xml b/pom.xml index 3f4514524..39a6a6370 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ - 1.12.1-Hoxton.SR12 + 1.12.2-Hoxton.SR12 5.2.25.RELEASE diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigChangeEventListener.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigChangeEventListener.java index d472f0a97..330e62fb0 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigChangeEventListener.java +++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/listener/PolarisConfigChangeEventListener.java @@ -26,6 +26,8 @@ import com.google.common.collect.Maps; import com.tencent.cloud.polaris.config.spring.event.ConfigChangeSpringEvent; import com.tencent.polaris.configuration.api.core.ConfigPropertyChangeInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.context.event.ApplicationStartedEvent; import org.springframework.cloud.context.environment.EnvironmentChangeEvent; @@ -37,6 +39,7 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import org.springframework.core.env.MutablePropertySources; +import org.springframework.core.env.StandardEnvironment; import org.springframework.lang.NonNull; import static com.tencent.cloud.polaris.config.listener.PolarisConfigListenerContext.fireConfigChange; @@ -50,6 +53,8 @@ */ public final class PolarisConfigChangeEventListener implements ApplicationListener, ApplicationEventPublisherAware { + private static final Logger LOG = LoggerFactory.getLogger(PolarisConfigChangeEventListener.class); + private static final AtomicBoolean started = new AtomicBoolean(); private ApplicationEventPublisher eventPublisher; @@ -96,12 +101,23 @@ private Map loadEnvironmentProperties(ConfigurableEnvironment en Map ret = Maps.newHashMap(); MutablePropertySources sources = environment.getPropertySources(); sources.iterator().forEachRemaining(propertySource -> { + // Don't read system env variable. + if (StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME.equals(propertySource.getName())) { + return; + } + Object o = propertySource.getSource(); if (o instanceof Map) { for (Map.Entry entry : ((Map) o).entrySet()) { String key = entry.getKey(); - String value = environment.getProperty(key); - ret.put(key, value); + try { + String value = environment.getProperty(key); + ret.put(key, value); + } + catch (Exception e) { + LOG.warn("Read property from {} with key {} failed.", propertySource.getName(), key, e); + } + } } else if (o instanceof Collection) { diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index d932fa9a8..0487e45db 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -70,7 +70,7 @@ - 1.12.1-Hoxton.SR12 + 1.12.2-Hoxton.SR12 1.14.1