Skip to content

Commit

Permalink
Fix spring spi extension keeps printing warn log during starting. (#6144
Browse files Browse the repository at this point in the history
)
  • Loading branch information
chickenlj committed Jun 8, 2021
1 parent 56367d5 commit badbbb4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
Expand Up @@ -118,9 +118,7 @@ public static int get(String property, int defaultValue) {

public static Map<String, String> parseProperties(String content) throws IOException {
Map<String, String> map = new HashMap<>();
if (StringUtils.isEmpty(content)) {
logger.warn("You specified the config center, but there's not even one single config item in it.");
} else {
if (StringUtils.isNotEmpty(content)) {
Properties properties = new Properties();
properties.load(new StringReader(content));
properties.stringPropertyNames().forEach(
Expand Down
Expand Up @@ -18,6 +18,7 @@

import org.apache.dubbo.common.context.FrameworkExt;
import org.apache.dubbo.common.context.LifecycleAdapter;
import org.apache.dubbo.common.extension.DisableInject;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.CollectionUtils;
Expand Down Expand Up @@ -76,7 +77,7 @@ public ConfigManager() {
}

// ApplicationConfig correlative methods

@DisableInject
public void setApplication(ApplicationConfig application) {
addConfig(application, true);
}
Expand All @@ -91,6 +92,7 @@ public ApplicationConfig getApplicationOrElseThrow() {

// MonitorConfig correlative methods

@DisableInject
public void setMonitor(MonitorConfig monitor) {
addConfig(monitor, true);
}
Expand All @@ -100,7 +102,7 @@ public Optional<MonitorConfig> getMonitor() {
}

// ModuleConfig correlative methods

@DisableInject
public void setModule(ModuleConfig module) {
addConfig(module, true);
}
Expand All @@ -109,6 +111,7 @@ public Optional<ModuleConfig> getModule() {
return ofNullable(getConfig(getTagName(ModuleConfig.class)));
}

@DisableInject
public void setMetrics(MetricsConfig metrics) {
addConfig(metrics, true);
}
Expand All @@ -117,6 +120,7 @@ public Optional<MetricsConfig> getMetrics() {
return ofNullable(getConfig(getTagName(MetricsConfig.class)));
}

@DisableInject
public void setSsl(SslConfig sslConfig) {
addConfig(sslConfig, true);
}
Expand Down
Expand Up @@ -79,6 +79,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -1033,8 +1034,17 @@ private DynamicConfiguration prepareEnvironment(ConfigCenterConfig configCenter)
}
try {
environment.setConfigCenterFirst(configCenter.isHighestPriority());
environment.updateExternalConfigurationMap(parseProperties(configContent));
environment.updateAppExternalConfigurationMap(parseProperties(appConfigContent));
Map<String, String> globalRemoteProperties = parseProperties(configContent);
if (CollectionUtils.isEmptyMap(globalRemoteProperties)) {
logger.info("No global configuration in config center");
}
environment.updateExternalConfigurationMap(globalRemoteProperties);

Map<String, String> appRemoteProperties = parseProperties(appConfigContent);
if (CollectionUtils.isEmptyMap(appRemoteProperties)) {
logger.info("No application level configuration in config center");
}
environment.updateAppExternalConfigurationMap(appRemoteProperties);
} catch (IOException e) {
throw new IllegalStateException("Failed to parse configurations from Config Center.", e);
}
Expand Down
Expand Up @@ -465,8 +465,7 @@ public static void validateSslConfig(SslConfig sslConfig) {
public static void validateMonitorConfig(MonitorConfig config) {
if (config != null) {
if (!config.isValid()) {
logger.info("There's no valid monitor config found, if you want to open monitor statistics for Dubbo, " +
"please make sure your monitor is configured properly.");
logger.info("No valid monitor config found, specify monitor info to enable collection of Dubbo statistics");
}

checkParameterName(config.getParameters());
Expand Down
Expand Up @@ -363,7 +363,6 @@ public void addObjectAttachmentsIfAbsent(Map<String, Object> attachments) {
}

@Override
@Deprecated
public String getAttachment(String key) {
if (attachments == null) {
return null;
Expand Down

0 comments on commit badbbb4

Please sign in to comment.