mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
[pr #1531]Improved nacos configuration parsing
This commit is contained in:
parent
d96b0759f4
commit
1710d827fb
@ -82,7 +82,7 @@ public final class NacosDataParserHandler {
|
||||
}
|
||||
NacosByteArrayResource nacosByteArrayResource = new NacosByteArrayResource(
|
||||
configValue.getBytes(), configName);
|
||||
nacosByteArrayResource.setFilename(configName + DOT + extension);
|
||||
nacosByteArrayResource.setFilename(getFileName(configName , extension));
|
||||
List<PropertySource<?>> propertySourceList = propertySourceLoader
|
||||
.load(configName, nacosByteArrayResource);
|
||||
if (CollectionUtils.isEmpty(propertySourceList)) {
|
||||
@ -135,6 +135,23 @@ public final class NacosDataParserHandler {
|
||||
return DEFAULT_EXTENSION;
|
||||
}
|
||||
|
||||
private String getFileName(String name,String extension){
|
||||
if(StringUtils.isEmpty(extension)){
|
||||
return name;
|
||||
}
|
||||
if (StringUtils.isEmpty(name)) {
|
||||
return extension;
|
||||
}
|
||||
int idx = name.lastIndexOf(DOT);
|
||||
if (idx > 0 && idx < name.length() - 1) {
|
||||
String ext = name.substring(idx + 1);
|
||||
if(extension.equalsIgnoreCase(ext)){
|
||||
return name;
|
||||
}
|
||||
}
|
||||
return name + DOT + extension;
|
||||
}
|
||||
|
||||
public static NacosDataParserHandler getInstance() {
|
||||
return ParserHandler.HANDLER;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user