Fixed bug when printing log with lower case name for datasource configure.
@@ -2,7 +2,7 @@ package com.ctrip.platform.dal.dao.configure;
import com.ctrip.platform.dal.dao.helper.ConnectionStringKeyNameHelper;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -22,7 +22,7 @@ public class DataSourceConfigureLocator {
private Map<String, DataSourceConfigure> dataSourceConfigures = new ConcurrentHashMap<>();
- private Set<String> dataSourceConfigureKeySet = new HashSet<>();
+ private Set<String> dataSourceConfigureKeySet = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
public DataSourceConfigure getUserDataSourceConfigure(String name) {
String keyName = ConnectionStringKeyNameHelper.getKeyName(name);
@@ -34,6 +34,22 @@ public class DataSourceConfigureLocator {
return dataSourceConfigures.get(keyName);
}
+ public void addDataSourceConfigureKeySet(Set<String> dbNames) {
+ if (dbNames == null || dbNames.isEmpty())
+ return;
+
+ for (String name : dbNames) {
+ addDataSourceConfigureKey(name);
+ }
+ }
+
+ private void addDataSourceConfigureKey(String name) {
+ if (name == null || name.isEmpty())
+ return;
+
+ dataSourceConfigureKeySet.add(name);
+ }
+
public Set<String> getDataSourceConfigureKeySet() {
return dataSourceConfigureKeySet;
}
@@ -46,7 +62,6 @@ public class DataSourceConfigureLocator {
public void addDataSourceConfigure(String name, DataSourceConfigure configure) {
String keyName = ConnectionStringKeyNameHelper.getKeyName(name);
dataSourceConfigures.put(keyName, configure);
- dataSourceConfigureKeySet.add(name);
}
public boolean contains(String name) {
