terrymanu commented on a change in pull request #11885:
URL: https://github.com/apache/shardingsphere/pull/11885#discussion_r691848934



##########
File path: 
shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/ClusterContextManagerBuilder.java
##########
@@ -111,7 +111,13 @@ private boolean isEmptyLocalSchemaRuleConfigurations(final 
Map<String, Collectio
         Map<String, Map<String, DataSourceConfiguration>> 
loadedDataSourceConfigs = loadDataSourceConfigurations(persistService, 
schemaNames);
         Map<String, Map<String, DataSourceConfiguration>> 
changedDataSourceConfigs = getChangedDataSourceConfigurations(dataSourcesMap, 
loadedDataSourceConfigs);
         Map<String, Map<String, DataSource>> result = new 
LinkedHashMap<>(dataSourcesMap);
-        result.putAll(getChangedDataSources(changedDataSourceConfigs));
+        
getChangedDataSources(changedDataSourceConfigs).entrySet().forEach(entry -> {
+            if (!result.containsKey(entry.getKey())) {

Review comment:
       Please reverse judge condition, it is better to use positive expression

##########
File path: 
shardingsphere-governance/shardingsphere-governance-context/src/main/java/org/apache/shardingsphere/governance/context/ClusterContextManagerBuilder.java
##########
@@ -123,10 +129,30 @@ private boolean 
isEmptyLocalSchemaRuleConfigurations(final Map<String, Collectio
         return result;
     }
     
-    // TODO finish this method
     private Map<String, Map<String, DataSourceConfiguration>> 
getChangedDataSourceConfigurations(final Map<String, Map<String, DataSource>> 
configuredDataSourcesMap, 
                                                                                
                  final Map<String, Map<String, DataSourceConfiguration>> 
loadedDataSourceConfigs) {
-        return isEmptyLocalDataSourcesMap(configuredDataSourcesMap) ? 
loadedDataSourceConfigs : Collections.emptyMap();
+        if (isEmptyLocalDataSourcesMap(configuredDataSourcesMap)) {
+            return loadedDataSourceConfigs;
+        }
+        Map<String, Map<String, DataSourceConfiguration>> result = new 
HashMap<>(loadedDataSourceConfigs.size(), 1);
+        for (Entry<String, Map<String, DataSourceConfiguration>> entry : 
loadedDataSourceConfigs.entrySet()) {
+            if (!configuredDataSourcesMap.containsKey(entry.getKey())) {

Review comment:
       Please reverse judge condition, it is better to use positive expression
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to