fix loading process cannot load environment variables. (#13091)
This commit is contained in:
parent
99ba6e3037
commit
cff9bfd1d2
|
|
@ -277,7 +277,7 @@ public final class ConfigurationUtils {
|
|||
for (Map.Entry<String, V> entry : copy.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
V val = entry.getValue();
|
||||
if (StringUtils.startsWithIgnoreCase(key, prefix)
|
||||
if ((StringUtils.startsWithIgnoreCase(key, prefix) || StringUtils.startsWithIgnoreCase(key, StringUtils.toOSStyleKey(prefix)))
|
||||
&& key.length() > prefix.length()
|
||||
&& !ConfigurationUtils.isEmptyValue(val)) {
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ public final class ConfigurationUtils {
|
|||
}
|
||||
for (Map.Entry<String, V> entry : copy.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (StringUtils.startsWithIgnoreCase(key, prefix)
|
||||
if ((StringUtils.startsWithIgnoreCase(key, prefix) || StringUtils.startsWithIgnoreCase(key, StringUtils.toOSStyleKey(prefix)))
|
||||
&& key.length() > prefix.length()
|
||||
&& !ConfigurationUtils.isEmptyValue(entry.getValue())) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
|
|||
* by default is false.
|
||||
*/
|
||||
private boolean isRegisterConsumerInstance() {
|
||||
Boolean registerConsumer = getApplication().getRegisterConsumer();
|
||||
Boolean registerConsumer = getApplicationOrElseThrow().getRegisterConsumer();
|
||||
if (registerConsumer == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
|
|||
|
||||
useRegistryAsMetadataCenterIfNecessary();
|
||||
|
||||
ApplicationConfig applicationConfig = getApplication();
|
||||
ApplicationConfig applicationConfig = getApplicationOrElseThrow();
|
||||
|
||||
String metadataType = applicationConfig.getMetadataType();
|
||||
// FIXME, multiple metadata config support.
|
||||
|
|
@ -858,14 +858,18 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
|
|||
if (StringUtils.isNotEmpty(configContent)) {
|
||||
logger.info(String.format("Got global remote configuration from config center with key-%s and group-%s: \n %s", configCenter.getConfigFile(), configCenter.getGroup(), configContent));
|
||||
}
|
||||
String appGroup = getApplication().getName();
|
||||
String appGroup = "";
|
||||
String appConfigContent = null;
|
||||
String appConfigFile = null;
|
||||
if (isNotEmpty(appGroup)) {
|
||||
appConfigFile = isNotEmpty(configCenter.getAppConfigFile()) ? configCenter.getAppConfigFile() : configCenter.getConfigFile();
|
||||
appConfigContent = dynamicConfiguration.getProperties(appConfigFile, appGroup);
|
||||
if (StringUtils.isNotEmpty(appConfigContent)) {
|
||||
logger.info(String.format("Got application specific remote configuration from config center with key %s and group %s: \n %s", appConfigFile, appGroup, appConfigContent));
|
||||
Optional<ApplicationConfig> applicationOptional = getApplication();
|
||||
if (applicationOptional.isPresent()) {
|
||||
appGroup = applicationOptional.get().getName();
|
||||
if (isNotEmpty(appGroup)) {
|
||||
appConfigFile = isNotEmpty(configCenter.getAppConfigFile()) ? configCenter.getAppConfigFile() : configCenter.getConfigFile();
|
||||
appConfigContent = dynamicConfiguration.getProperties(appConfigFile, appGroup);
|
||||
if (StringUtils.isNotEmpty(appConfigContent)) {
|
||||
logger.info(String.format("Got application specific remote configuration from config center with key %s and group %s: \n %s", appConfigFile, appGroup, appConfigContent));
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
@ -1322,9 +1326,12 @@ public class DefaultApplicationDeployer extends AbstractDeployer<ApplicationMode
|
|||
}
|
||||
}
|
||||
|
||||
private ApplicationConfig getApplication() {
|
||||
private ApplicationConfig getApplicationOrElseThrow() {
|
||||
return configManager.getApplicationOrElseThrow();
|
||||
}
|
||||
|
||||
private Optional<ApplicationConfig> getApplication() {
|
||||
return configManager.getApplication();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -917,7 +917,7 @@ public class RegistryProtocol implements Protocol, ScopeModelAware {
|
|||
public ProviderConfigurationListener(ModuleModel moduleModel) {
|
||||
super(moduleModel);
|
||||
this.moduleModel = moduleModel;
|
||||
if (moduleModel.modelEnvironment().getConfiguration().convert(Boolean.class, ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
if (moduleModel.modelEnvironment().getConfiguration().getBoolean(ENABLE_CONFIGURATION_LISTEN, true)) {
|
||||
this.initWith(moduleModel.getApplicationModel().getApplicationName() + CONFIGURATORS_SUFFIX);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import org.apache.dubbo.common.constants.CommonConstants;
|
|||
import org.apache.dubbo.common.extension.ExtensionLoader;
|
||||
import org.apache.dubbo.common.utils.JsonUtils;
|
||||
import org.apache.dubbo.common.utils.NetUtils;
|
||||
|
||||
import org.apache.dubbo.rpc.Exporter;
|
||||
import org.apache.dubbo.rpc.Invoker;
|
||||
import org.apache.dubbo.rpc.Protocol;
|
||||
|
|
@ -31,13 +30,11 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
|
|||
import org.apache.dubbo.rpc.model.ModuleServiceRepository;
|
||||
import org.apache.dubbo.rpc.model.ProviderModel;
|
||||
import org.apache.dubbo.rpc.model.ServiceDescriptor;
|
||||
|
||||
import org.apache.dubbo.rpc.protocol.rest.noannotation.NoAnnotationDemoService;
|
||||
import org.apache.dubbo.rpc.protocol.rest.noannotation.NoAnnotationDemoServiceImpl;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -53,6 +50,12 @@ class NoAnnotationRestProtocolTest {
|
|||
public void tearDown() {
|
||||
protocol.destroy();
|
||||
FrameworkModel.destroyAll();
|
||||
new JsonUtils() {
|
||||
public void clearJson() {
|
||||
setJson(null);
|
||||
}
|
||||
}.clearJson();
|
||||
System.clearProperty(CommonConstants.PREFER_JSON_FRAMEWORK_NAME);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue