1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

optimize code to match p3c check rules

Signed-off-by: jimin.jm <jimin.jm@alibaba-inc.com>
This commit is contained in:
jimin.jm
2019-05-08 20:27:23 +08:00
parent f7047f8be6
commit 4dcd68f6e1
21 changed files with 74 additions and 40 deletions

View File

@@ -28,25 +28,25 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class NacosPropertySourceRepository {
private final static ConcurrentHashMap<String, NacosPropertySource> nacosPropertySourceRepository = new ConcurrentHashMap<>();
private final static ConcurrentHashMap<String, NacosPropertySource> NACOS_PROPERTY_SOURCE_REPOSITORY = new ConcurrentHashMap<>();
/**
* @return all nacos properties from application context
*/
public static List<NacosPropertySource> getAll() {
List<NacosPropertySource> result = new ArrayList<>();
result.addAll(nacosPropertySourceRepository.values());
result.addAll(NACOS_PROPERTY_SOURCE_REPOSITORY.values());
return result;
}
public static void collectNacosPropertySources(
NacosPropertySource nacosPropertySource) {
nacosPropertySourceRepository.putIfAbsent(nacosPropertySource.getDataId(),
NACOS_PROPERTY_SOURCE_REPOSITORY.putIfAbsent(nacosPropertySource.getDataId(),
nacosPropertySource);
}
public static NacosPropertySource getNacosPropertySource(String dataId) {
return nacosPropertySourceRepository.get(dataId);
return NACOS_PROPERTY_SOURCE_REPOSITORY.get(dataId);
}
}