This commit is contained in:
parent
557464bd2c
commit
369f19608e
@ -34,6 +34,7 @@ import com.alibaba.nacos.client.config.utils.ParamUtils;
|
||||
import com.alibaba.nacos.client.config.utils.TenantUtil;
|
||||
import com.alibaba.nacos.client.utils.LogUtils;
|
||||
import com.alibaba.nacos.client.utils.StringUtils;
|
||||
import com.alibaba.nacos.client.utils.TemplateUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -42,6 +43,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Config Impl
|
||||
@ -82,14 +84,20 @@ public class NacosConfigService implements ConfigService {
|
||||
private void initNamespace(Properties properties) {
|
||||
String namespaceTmp = properties.getProperty(PropertyKeyConst.NAMESPACE);
|
||||
|
||||
if (StringUtils.isBlank(namespaceTmp)) {
|
||||
namespaceTmp = TenantUtil.getUserTenant();
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(namespaceTmp)) {
|
||||
namespaceTmp = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_NAMESPACE);
|
||||
}
|
||||
namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return TenantUtil.getUserTenant();
|
||||
}
|
||||
});
|
||||
|
||||
namespaceTmp = TemplateUtils.stringBlankAndThenExecute(namespaceTmp, new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
String namespace = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_NAMESPACE);
|
||||
return StringUtils.isNotBlank(namespace) ? namespace : "";
|
||||
}
|
||||
});
|
||||
namespace = namespaceTmp;
|
||||
properties.put(PropertyKeyConst.NAMESPACE, namespace);
|
||||
}
|
||||
|
@ -174,7 +174,8 @@ public class ServerListManager {
|
||||
return TemplateUtils.stringBlankAndThenExecute(endpointTmp, new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);
|
||||
String endpointUrl = System.getenv(PropertyKeyConst.SystemEnv.ALIBABA_ALIWARE_ENDPOINT_URL);
|
||||
return StringUtils.isNotBlank(endpointUrl) ? endpointUrl : "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class NacosNamingService implements NamingService {
|
||||
}
|
||||
});
|
||||
|
||||
if (StringUtils.isEmpty(endpointUrl)) {
|
||||
if (com.alibaba.nacos.client.utils.StringUtils.isNotBlank(endpointUrl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user