This is an automated email from the ASF dual-hosted git repository.

zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 2e28084  Add props param into DataSourceProperties's constructor 
(#14797)
2e28084 is described below

commit 2e28084d7a4a695393f3fac0dd5435ab625542aa
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Jan 15 15:53:56 2022 +0800

    Add props param into DataSourceProperties's constructor (#14797)
---
 .../datasource/props/DataSourceProperties.java     | 15 +++-
 .../props/DataSourcePropertiesCreator.java         |  4 +-
 .../YamlDataSourceConfigurationSwapper.java        | 17 +++--
 .../pool/creator/DataSourcePoolCreatorTest.java    | 49 ++++++------
 .../props/DataSourcePropertiesCreatorTest.java     | 18 ++---
 .../datasource/props/DataSourcePropertiesTest.java | 86 ++++++++++------------
 .../props/DataSourcePropertiesValidatorTest.java   | 28 +++----
 .../YamlDataSourcePropertiesSwapperTest.java       | 12 ++-
 .../jdbc/core/connection/ConnectionManager.java    |  4 +-
 .../core/connection/ConnectionManagerTest.java     | 16 ++--
 .../mode/manager/ContextManagerTest.java           | 22 +++---
 .../rdl/resource/ResourceSegmentsConverter.java    | 13 +++-
 .../distsql/rql/DataSourceQueryResultSetTest.java  | 10 ++-
 .../ProxyResourceConfigurationConverter.java       | 25 ++++---
 14 files changed, 164 insertions(+), 155 deletions(-)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
index fb137d4..ad16a66 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourceProperties.java
@@ -19,10 +19,10 @@ package 
org.apache.shardingsphere.infra.config.datasource.props;
 
 import com.google.common.base.Objects;
 import lombok.Getter;
-import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData;
+import 
org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaDataFactory;
 
 import java.util.HashMap;
-import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
@@ -30,7 +30,6 @@ import java.util.Properties;
 /**
  * Data source properties.
  */
-@RequiredArgsConstructor
 @Getter
 public final class DataSourceProperties {
     
@@ -38,10 +37,18 @@ public final class DataSourceProperties {
     
     private final String dataSourceClassName;
     
-    private final Map<String, Object> props = new LinkedHashMap<>();
+    private final DataSourcePoolMetaData poolMetaData;
+    
+    private final Map<String, Object> props;
     
     private final Properties customPoolProps = new Properties();
     
+    public DataSourceProperties(final String dataSourceClassName, final 
Map<String, Object> props) {
+        this.dataSourceClassName = dataSourceClassName;
+        this.props = props;
+        poolMetaData = 
DataSourcePoolMetaDataFactory.newInstance(dataSourceClassName);
+    }
+    
     /**
      * Add property synonym to shared configuration.
      *
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
index d4d1d94..c328178 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
@@ -52,9 +52,7 @@ public final class DataSourcePropertiesCreator {
      * @return created data source properties
      */
     public static DataSourceProperties create(final DataSource dataSource) {
-        DataSourceProperties result = new 
DataSourceProperties(dataSource.getClass().getName());
-        result.getProps().putAll(createProperties(dataSource));
-        return result;
+        return new DataSourceProperties(dataSource.getClass().getName(), 
createProperties(dataSource));
     }
     
     private static Map<String, Object> createProperties(final DataSource 
dataSource) {
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourceConfigurationSwapper.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourceConfigurationSwapper.java
index 9e8869f1..f4a31d8 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourceConfigurationSwapper.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourceConfigurationSwapper.java
@@ -68,14 +68,17 @@ public final class YamlDataSourceConfigurationSwapper {
     @SuppressWarnings("rawtypes")
     public DataSourceProperties swapToDataSourceProperties(final Map<String, 
Object> yamlConfig) {
         
Preconditions.checkState(yamlConfig.containsKey(DATA_SOURCE_CLASS_NAME_KEY), 
"%s can not be null.", DATA_SOURCE_CLASS_NAME_KEY);
-        Map<String, Object> newDataSourceMap = new HashMap<>(yamlConfig);
-        newDataSourceMap.remove(DATA_SOURCE_CLASS_NAME_KEY);
-        DataSourceProperties result = new 
DataSourceProperties(yamlConfig.get(DATA_SOURCE_CLASS_NAME_KEY).toString());
-        if (null != 
newDataSourceMap.get(DataSourceProperties.CUSTOM_POOL_PROPS_KEY)) {
-            result.getCustomPoolProps().putAll((Map) 
newDataSourceMap.get(DataSourceProperties.CUSTOM_POOL_PROPS_KEY));
-            
newDataSourceMap.remove(DataSourceProperties.CUSTOM_POOL_PROPS_KEY);
+        DataSourceProperties result = new 
DataSourceProperties(yamlConfig.get(DATA_SOURCE_CLASS_NAME_KEY).toString(), 
getProperties(yamlConfig));
+        if (null != 
yamlConfig.get(DataSourceProperties.CUSTOM_POOL_PROPS_KEY)) {
+            result.getCustomPoolProps().putAll((Map) 
yamlConfig.get(DataSourceProperties.CUSTOM_POOL_PROPS_KEY));
         }
-        result.getProps().putAll(newDataSourceMap);
+        return result;
+    }
+    
+    private Map<String, Object> getProperties(final Map<String, Object> 
yamlConfig) {
+        Map<String, Object> result = new HashMap<>(yamlConfig);
+        result.remove(DATA_SOURCE_CLASS_NAME_KEY);
+        result.remove(DataSourceProperties.CUSTOM_POOL_PROPS_KEY);
         return result;
     }
     
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorTest.java
index 40d839b..9033886 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorTest.java
@@ -26,6 +26,7 @@ import org.junit.Test;
 import javax.sql.CommonDataSource;
 import javax.sql.DataSource;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
@@ -38,7 +39,7 @@ public final class DataSourcePoolCreatorTest {
     @Test
     public void assertCreateMap() {
         Map<String, DataSourceProperties> dataSourcePropsMap = new 
HashMap<>(1, 1);
-        dataSourcePropsMap.put("foo_ds", createDataSourceProperties());
+        dataSourcePropsMap.put("foo_ds", new 
DataSourceProperties(MockedDataSource.class.getName(), createProperties()));
         Map<String, DataSource> actual = 
DataSourcePoolCreator.create(dataSourcePropsMap);
         assertThat(actual.size(), is(1));
         assertDataSource((MockedDataSource) actual.get("foo_ds"));
@@ -46,17 +47,17 @@ public final class DataSourcePoolCreatorTest {
     
     @Test
     public void assertCreate() {
-        MockedDataSource actual = (MockedDataSource) 
DataSourcePoolCreator.create(createDataSourceProperties());
+        MockedDataSource actual = (MockedDataSource) 
DataSourcePoolCreator.create(new 
DataSourceProperties(MockedDataSource.class.getName(), createProperties()));
         assertThat(actual.getDriverClassName(), 
is(MockedDataSource.class.getName()));
         assertDataSource(actual);
     }
     
-    private DataSourceProperties createDataSourceProperties() {
-        DataSourceProperties result = new 
DataSourceProperties(MockedDataSource.class.getName());
-        result.getProps().put("driverClassName", 
MockedDataSource.class.getName());
-        result.getProps().put("url", "jdbc:mock://127.0.0.1/foo_ds");
-        result.getProps().put("username", "root");
-        result.getProps().put("password", "root");
+    private Map<String, Object> createProperties() {
+        Map<String, Object> result = new LinkedHashMap<>();
+        result.put("driverClassName", MockedDataSource.class.getName());
+        result.put("url", "jdbc:mock://127.0.0.1/foo_ds");
+        result.put("username", "root");
+        result.put("password", "root");
         return result;
     }
     
@@ -70,33 +71,29 @@ public final class DataSourcePoolCreatorTest {
     
     @Test
     public void assertCreateDefaultDataSource() {
-        
assertThat(DataSourcePoolCreator.create(createDefaultDataSourceProperties()), 
instanceOf(CommonDataSource.class));
+        assertThat(DataSourcePoolCreator.create(new 
DataSourceProperties(BasicDataSource.class.getName(), 
createDefaultProperties())), instanceOf(CommonDataSource.class));
     }
     
-    private DataSourceProperties createDefaultDataSourceProperties() {
-        Map<String, Object> props = new HashMap<>();
-        props.put("driverClassName", MockedDataSource.class.getName());
-        props.put("url", "jdbc:mock://127.0.0.1/foo_ds");
-        props.put("username", "root");
-        props.put("password", "root");
-        DataSourceProperties result = new 
DataSourceProperties(BasicDataSource.class.getName());
-        result.getProps().putAll(props);
+    private Map<String, Object> createDefaultProperties() {
+        Map<String, Object> result = new HashMap<>();
+        result.put("driverClassName", MockedDataSource.class.getName());
+        result.put("url", "jdbc:mock://127.0.0.1/foo_ds");
+        result.put("username", "root");
+        result.put("password", "root");
         return result;
     }
     
     @Test
     public void assertCreateHikariDataSource() {
-        
assertThat(DataSourcePoolCreator.create(createHikariDataSourceProperties()), 
instanceOf(HikariDataSource.class));
+        assertThat(DataSourcePoolCreator.create(new 
DataSourceProperties(HikariDataSource.class.getName(), 
createHikariProperties())), instanceOf(HikariDataSource.class));
     }
     
-    private DataSourceProperties createHikariDataSourceProperties() {
-        Map<String, Object> props = new HashMap<>();
-        props.put("jdbcUrl", "jdbc:mock://127.0.0.1/foo_ds");
-        props.put("driverClassName", MockedDataSource.class.getName());
-        props.put("username", "root");
-        props.put("password", "root");
-        DataSourceProperties result = new 
DataSourceProperties(HikariDataSource.class.getName());
-        result.getProps().putAll(props);
+    private Map<String, Object> createHikariProperties() {
+        Map<String, Object> result = new HashMap<>();
+        result.put("jdbcUrl", "jdbc:mock://127.0.0.1/foo_ds");
+        result.put("driverClassName", MockedDataSource.class.getName());
+        result.put("username", "root");
+        result.put("password", "root");
         return result;
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
index f1120b7..cf0e3dd 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
@@ -35,12 +35,12 @@ public final class DataSourcePropertiesCreatorTest {
         dataSourceMap.put("foo_ds", createDataSource());
         Map<String, DataSourceProperties> actual = 
DataSourcePropertiesCreator.create(dataSourceMap);
         assertThat(actual.size(), is(1));
-        assertThat(actual.get("foo_ds"), is(createDataSourceProperties()));
+        assertThat(actual.get("foo_ds"), is(new 
DataSourceProperties(MockedDataSource.class.getName(), createProperties())));
     }
     
     @Test
     public void assertCreate() {
-        assertThat(DataSourcePropertiesCreator.create(createDataSource()), 
is(createDataSourceProperties()));
+        assertThat(DataSourcePropertiesCreator.create(createDataSource()), 
is(new DataSourceProperties(MockedDataSource.class.getName(), 
createProperties())));
     }
     
     private DataSource createDataSource() {
@@ -52,13 +52,13 @@ public final class DataSourcePropertiesCreatorTest {
         return result;
     }
     
-    private DataSourceProperties createDataSourceProperties() {
-        DataSourceProperties result = new 
DataSourceProperties(MockedDataSource.class.getName());
-        result.getProps().put("driverClassName", 
MockedDataSource.class.getName());
-        result.getProps().put("url", "jdbc:mock://127.0.0.1/foo_ds");
-        result.getProps().put("username", "root");
-        result.getProps().put("password", "root");
-        result.getProps().put("maximumPoolSize", "-1");
+    private Map<String, Object> createProperties() {
+        Map<String, Object> result = new HashMap<>();
+        result.put("driverClassName", MockedDataSource.class.getName());
+        result.put("url", "jdbc:mock://127.0.0.1/foo_ds");
+        result.put("username", "root");
+        result.put("password", "root");
+        result.put("maximumPoolSize", "-1");
         return result;
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
index a690ae6..e0b9ba9 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesTest.java
@@ -26,9 +26,9 @@ import org.junit.rules.ExpectedException;
 
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.hasItem;
 import static org.hamcrest.CoreMatchers.instanceOf;
@@ -66,60 +66,49 @@ public final class DataSourcePropertiesTest {
     
     @Test
     public void assertEquals() {
-        DataSourceProperties originalDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        DataSourceProperties targetDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        assertThat(originalDataSourceProps, is(originalDataSourceProps));
-        assertThat(originalDataSourceProps, is(targetDataSourceProps));
-        originalDataSourceProps.getProps().put("username", "root");
-        targetDataSourceProps.getProps().put("username", "root");
-        assertThat(originalDataSourceProps, is(targetDataSourceProps));
-        targetDataSourceProps.getProps().put("password", "root");
-        assertThat(originalDataSourceProps, is(targetDataSourceProps));
+        assertThat(new DataSourceProperties(MockedDataSource.class.getName(), 
createUserProperties("root")), 
+                is(new DataSourceProperties(MockedDataSource.class.getName(), 
createUserProperties("root"))));
     }
     
     @Test
     public void assertNotEqualsWithNullValue() {
-        assertFalse(new 
DataSourceProperties("FooDataSourceClass").equals(null));
+        assertFalse(new DataSourceProperties(MockedDataSource.class.getName(), 
new HashMap<>()).equals(null));
     }
     
     @Test
     public void assertNotEqualsWithDifferentDataSourceClassName() {
-        assertThat(new DataSourceProperties("FooDataSourceClass"), not(new 
DataSourceProperties("BarDataSourceClass")));
+        assertThat(new DataSourceProperties("FooDataSourceClass", new 
HashMap<>()), not(new DataSourceProperties("BarDataSourceClass", new 
HashMap<>())));
     }
     
     @Test
     public void assertNotEqualsWithDifferentProperties() {
-        DataSourceProperties originalDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        DataSourceProperties targetDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        originalDataSourceProps.getProps().put("username", "root");
-        targetDataSourceProps.getProps().put("username", "root0");
-        assertThat(originalDataSourceProps, not(targetDataSourceProps));
+        DataSourceProperties actual = new 
DataSourceProperties(MockedDataSource.class.getName(), 
createUserProperties("foo"));
+        DataSourceProperties expected = new 
DataSourceProperties(MockedDataSource.class.getName(), 
createUserProperties("bar"));
+        assertThat(actual, not(expected));
     }
     
     @Test
     public void assertSameHashCode() {
-        DataSourceProperties originalDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        DataSourceProperties targetDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        assertThat(originalDataSourceProps.hashCode(), 
is(targetDataSourceProps.hashCode()));
-        originalDataSourceProps.getProps().put("username", "root");
-        targetDataSourceProps.getProps().put("username", "root");
-        assertThat(originalDataSourceProps.hashCode(), 
is(targetDataSourceProps.hashCode()));
-        originalDataSourceProps.getProps().put("password", "root");
-        targetDataSourceProps.getProps().put("password", "root");
-        assertThat(originalDataSourceProps.hashCode(), 
is(targetDataSourceProps.hashCode()));
+        assertThat(new DataSourceProperties(MockedDataSource.class.getName(), 
createUserProperties("root")).hashCode(), 
+                is(new DataSourceProperties(MockedDataSource.class.getName(), 
createUserProperties("root")).hashCode()));
     }
     
     @Test
-    public void assertDifferentHashCode() {
-        DataSourceProperties originalDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        DataSourceProperties targetDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        originalDataSourceProps.getProps().put("username", "root");
-        targetDataSourceProps.getProps().put("username", "root");
-        targetDataSourceProps.getProps().put("password", "root");
-        assertThat(originalDataSourceProps.hashCode(), 
not(targetDataSourceProps.hashCode()));
-        originalDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        targetDataSourceProps = new DataSourceProperties("BarDataSourceClass");
-        assertThat(originalDataSourceProps.hashCode(), 
not(targetDataSourceProps.hashCode()));
+    public void assertDifferentHashCodeWithDifferentDataSourceClassName() {
+        assertThat(new DataSourceProperties("FooDataSourceClass", 
createUserProperties("foo")).hashCode(),
+                not(new DataSourceProperties("BarDataSourceClass", 
createUserProperties("foo")).hashCode()));
+    }
+    
+    @Test
+    public void assertDifferentHashCodeWithDifferentProperties() {
+        assertThat(new DataSourceProperties(MockedDataSource.class.getName(), 
createUserProperties("foo")).hashCode(), 
+                not(new DataSourceProperties(MockedDataSource.class.getName(), 
createUserProperties("bar")).hashCode()));
+    }
+    
+    private Map<String, Object> createUserProperties(final String username) {
+        Map<String, Object> result = new LinkedHashMap<>(1, 1);
+        result.put("username", username);
+        return result;
     }
     
     @SuppressWarnings("unchecked")
@@ -146,18 +135,7 @@ public final class DataSourcePropertiesTest {
     
     @Test
     public void assertGetAllProperties() {
-        Map<String, Object> props = new HashMap<>(16, 1);
-        props.put("driverClassName", 
MockedDataSource.class.getCanonicalName());
-        props.put("jdbcUrl", "jdbc:mock://127.0.0.1/foo_ds");
-        props.put("username", "root");
-        props.put("password", "root");
-        props.put("loginTimeout", "5000");
-        Properties customPoolProps = new Properties();
-        customPoolProps.setProperty("maximumPoolSize", "30");
-        customPoolProps.setProperty("idleTimeout", "30000");
-        DataSourceProperties originalDataSourceProps = new 
DataSourceProperties("FooDataSourceClass");
-        originalDataSourceProps.getProps().putAll(props);
-        originalDataSourceProps.getProps().putAll(new 
HashMap(customPoolProps));
+        DataSourceProperties originalDataSourceProps = new 
DataSourceProperties(MockedDataSource.class.getName(), getProperties());
         Map<String, Object> actualAllProperties = 
originalDataSourceProps.getAllProperties();
         assertNotNull(actualAllProperties);
         assertThat(actualAllProperties.size(), is(7));
@@ -176,4 +154,16 @@ public final class DataSourcePropertiesTest {
         assertTrue(actualAllProperties.containsKey("idleTimeout"));
         assertTrue(actualAllProperties.containsValue("30000"));
     }
+    
+    private Map<String, Object> getProperties() {
+        Map<String, Object> result = new HashMap<>(7, 1);
+        result.put("driverClassName", 
MockedDataSource.class.getCanonicalName());
+        result.put("jdbcUrl", "jdbc:mock://127.0.0.1/foo_ds");
+        result.put("username", "root");
+        result.put("password", "root");
+        result.put("loginTimeout", "5000");
+        result.put("maximumPoolSize", "30");
+        result.put("idleTimeout", "30000");
+        return result;
+    }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesValidatorTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesValidatorTest.java
index 59ece48..02d04c2 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesValidatorTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesValidatorTest.java
@@ -30,32 +30,26 @@ public final class DataSourcePropertiesValidatorTest {
     
     @Test
     public void assertValidateSuccess() throws InvalidResourcesException {
-        DataSourcePropertiesValidator validator = new 
DataSourcePropertiesValidator();
-        validator.validate(Collections.singletonMap("name", 
createValidDataSourceProperties()));
+        new 
DataSourcePropertiesValidator().validate(Collections.singletonMap("name", new 
DataSourceProperties(HikariDataSource.class.getName(), 
createValidProperties())));
     }
     
-    private DataSourceProperties createValidDataSourceProperties() {
-        Map<String, Object> props = new HashMap<>();
-        props.put("driverClassName", 
MockedDataSource.class.getCanonicalName());
-        props.put("jdbcUrl", "jdbc:mock://127.0.0.1/foo_ds");
-        props.put("username", "root");
-        props.put("password", "root");
-        DataSourceProperties result = new 
DataSourceProperties(HikariDataSource.class.getName());
-        result.getProps().putAll(props);
+    private Map<String, Object> createValidProperties() {
+        Map<String, Object> result = new HashMap<>();
+        result.put("driverClassName", MockedDataSource.class.getName());
+        result.put("jdbcUrl", "jdbc:mock://127.0.0.1/foo_ds");
+        result.put("username", "root");
+        result.put("password", "root");
         return result;
     }
     
     @Test(expected = InvalidResourcesException.class)
     public void assertValidateFailed() throws InvalidResourcesException {
-        DataSourcePropertiesValidator validator = new 
DataSourcePropertiesValidator();
-        validator.validate(Collections.singletonMap("name", 
createInvalidDataSourceProperties()));
+        new 
DataSourcePropertiesValidator().validate(Collections.singletonMap("name", new 
DataSourceProperties(HikariDataSource.class.getName(), 
createInvalidProperties())));
     }
     
-    private DataSourceProperties createInvalidDataSourceProperties() {
-        Map<String, Object> props = new HashMap<>();
-        props.put("driverClassName", "InvalidDriver");
-        DataSourceProperties result = new 
DataSourceProperties(HikariDataSource.class.getName());
-        result.getProps().putAll(props);
+    private Map<String, Object> createInvalidProperties() {
+        Map<String, Object> result = new HashMap<>();
+        result.put("driverClassName", "InvalidDriver");
         return result;
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourcePropertiesSwapperTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourcePropertiesSwapperTest.java
index b9eb65b..ea5d85e 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourcePropertiesSwapperTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/YamlDataSourcePropertiesSwapperTest.java
@@ -65,15 +65,19 @@ public final class YamlDataSourcePropertiesSwapperTest {
     
     @Test
     public void assertSwapToMap() {
-        DataSourceProperties dataSourceProps = new 
DataSourceProperties(MockedDataSource.class.getCanonicalName());
-        dataSourceProps.getProps().put("url", "xx:xxx");
-        dataSourceProps.getProps().put("username", "root");
-        Map<String, Object> actual = swapper.swapToMap(dataSourceProps);
+        Map<String, Object> actual = swapper.swapToMap(new 
DataSourceProperties(MockedDataSource.class.getName(), createProperties()));
         assertThat(actual.get("dataSourceClassName"), 
is(MockedDataSource.class.getCanonicalName()));
         assertThat(actual.get("url").toString(), is("xx:xxx"));
         assertThat(actual.get("username").toString(), is("root"));
     }
     
+    private Map<String, Object> createProperties() {
+        Map<String, Object> result = new LinkedHashMap<>(2, 1);
+        result.put("url", "xx:xxx");
+        result.put("username", "root");
+        return result;
+    }
+    
     private Map<String, Map<String, Object>> createYamlConfig() {
         Map<String, Map<String, Object>> result = new LinkedHashMap<>(2, 1);
         result.put("ds_0", createPropertyMap("ds_0"));
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
index 732d748..b3face2 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManager.java
@@ -116,9 +116,7 @@ public final class ConnectionManager implements 
ExecutorJDBCManager, AutoCloseab
         ShardingSphereUser user = users.iterator().next();
         props.put("username", user.getGrantee().getUsername());
         props.put("password", user.getPassword());
-        DataSourceProperties result = new 
DataSourceProperties(HikariDataSource.class.getName());
-        result.getProps().putAll(props);
-        return result;
+        return new DataSourceProperties(HikariDataSource.class.getName(), 
props);
     }
     
     private String createJdbcUrl(final ComputeNodeInstance instance, final 
String schema, final Map<String, Object> props) {
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
index 304cdbb..312311e 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
@@ -104,12 +104,16 @@ public final class ConnectionManagerTest {
     }
     
     private Map<String, DataSourceProperties> createDataSourcePropertiesMap() {
-        Map<String, DataSourceProperties> result = new LinkedHashMap<>();
-        DataSourceProperties dataSourceProps = new 
DataSourceProperties(HikariDataSource.class.getName());
-        result.put(DefaultSchema.LOGIC_NAME, dataSourceProps);
-        dataSourceProps.getProps().put("jdbcUrl", 
"jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false");
-        dataSourceProps.getProps().put("username", "root");
-        dataSourceProps.getProps().put("password", "123456");
+        Map<String, DataSourceProperties> result = new LinkedHashMap<>(1, 1);
+        result.put(DefaultSchema.LOGIC_NAME, new 
DataSourceProperties(HikariDataSource.class.getName(), createProperties()));
+        return result;
+    }
+    
+    private Map<String, Object> createProperties() {
+        Map<String, Object> result = new LinkedHashMap<>(3, 1);
+        result.put("jdbcUrl", 
"jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false");
+        result.put("username", "root");
+        result.put("password", "123456");
         return result;
     }
     
diff --git 
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
 
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
index 21e50f6..a97e300 100644
--- 
a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
+++ 
b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/manager/ContextManagerTest.java
@@ -233,8 +233,8 @@ public final class ContextManagerTest {
         Properties dataSourceProps = new Properties();
         dataSourceProps.put("jdbcUrl", "jdbc:mock://127.0.0.1/foo_ds");
         Map<String, DataSourceProperties> result = new LinkedHashMap<>();
-        result.put("test_ds_1", createDataSourceProperties(dataSourceProps));
-        result.put("test_ds_2", createDataSourceProperties(dataSourceProps));
+        result.put("test_ds_1", new 
DataSourceProperties(MockedDataSource.class.getName(), 
createProperties(dataSourceProps)));
+        result.put("test_ds_2", new 
DataSourceProperties(MockedDataSource.class.getName(), 
createProperties(dataSourceProps)));
         return result;
     }
     
@@ -284,7 +284,7 @@ public final class ContextManagerTest {
         dataSourceProps.put("username", "test");
         dataSourceProps.put("password", "test");
         Map<String, DataSourceProperties> result = new LinkedHashMap<>();
-        result.put("test_ds", createDataSourceProperties(dataSourceProps));
+        result.put("test_ds", new 
DataSourceProperties(MockedDataSource.class.getName(), 
createProperties(dataSourceProps)));
         return result;
     }
     
@@ -360,7 +360,7 @@ public final class ContextManagerTest {
         Properties dataSourceProps = new Properties();
         dataSourceProps.put("username", "test");
         dataSourceProps.put("password", "test");
-        newDataSourceProps.put("ds_1", 
createDataSourceProperties(dataSourceProps));
+        newDataSourceProps.put("ds_1", new 
DataSourceProperties(MockedDataSource.class.getName(), 
createProperties(dataSourceProps)));
         contextManager.alterDataSourceConfiguration("test_schema", 
newDataSourceProps);
         
assertTrue(contextManager.getMetaDataContexts().getMetaDataMap().containsKey("test_schema"));
         
assertThat(contextManager.getMetaDataContexts().getMetaDataMap().get("test_schema").getResource().getDataSources().size(),
 is(1));
@@ -441,14 +441,12 @@ public final class ContextManagerTest {
         
assertTrue(contextManager.getMetaDataContexts().getMetaData("test_schema").getResource().getDataSources().containsKey("test_ds"));
     }
     
-    private DataSourceProperties createDataSourceProperties(final Properties 
dataSourceProps) {
-        Map<String, Object> props = new HashMap(dataSourceProps);
-        props.putIfAbsent("driverClassName", 
MockedDataSource.class.getCanonicalName());
-        props.putIfAbsent("url", "jdbc:mock://127.0.0.1/foo_ds");
-        props.putIfAbsent("username", "root");
-        props.putIfAbsent("password", "root");
-        DataSourceProperties result = new 
DataSourceProperties(MockedDataSource.class.getCanonicalName());
-        result.getProps().putAll(props);
+    private Map<String, Object> createProperties(final Properties 
dataSourceProps) {
+        Map<String, Object> result = new HashMap(dataSourceProps);
+        result.putIfAbsent("driverClassName", 
MockedDataSource.class.getName());
+        result.putIfAbsent("url", "jdbc:mock://127.0.0.1/foo_ds");
+        result.putIfAbsent("username", "root");
+        result.putIfAbsent("password", "root");
         return result;
     }
     
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverter.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverter.java
index 97ff740..dd69b44 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverter.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverter.java
@@ -50,16 +50,21 @@ public final class ResourceSegmentsConverter {
     }
     
     private static DataSourceProperties createDataSourceProperties(final 
DatabaseType databaseType, final DataSourceSegment segment) {
-        DataSourceProperties result = new 
DataSourceProperties(HikariDataSource.class.getCanonicalName());
-        result.getProps().put("jdbcUrl", getURL(databaseType, segment));
-        result.getProps().put("username", segment.getUser());
-        result.getProps().put("password", segment.getPassword());
+        DataSourceProperties result = new 
DataSourceProperties(HikariDataSource.class.getCanonicalName(), 
createProperties(databaseType, segment));
         if (null != segment.getProperties()) {
             result.getCustomPoolProps().putAll(segment.getProperties());
         }
         return result;
     }
     
+    private static Map<String, Object> createProperties(final DatabaseType 
databaseType, final DataSourceSegment segment) {
+        Map<String, Object> result = new LinkedHashMap<>();
+        result.put("jdbcUrl", getURL(databaseType, segment));
+        result.put("username", segment.getUser());
+        result.put("password", segment.getPassword());
+        return result;
+    }
+    
     private static String getURL(final DatabaseType databaseType, final 
DataSourceSegment segment) {
         if (null != segment.getUrl()) {
             return segment.getUrl();
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/DataSourceQueryResultSetTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/DataSourceQueryResultSetTest.java
index d26eea6..4de889a 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/DataSourceQueryResultSetTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/DataSourceQueryResultSetTest.java
@@ -42,6 +42,7 @@ import javax.sql.DataSource;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Optional;
 
@@ -123,10 +124,15 @@ public final class DataSourceQueryResultSetTest {
     
     private Map<String, DataSourceProperties> createDataSourcePropertiesMap() {
         Map<String, DataSourceProperties> result = new HashMap<>();
-        DataSourceProperties ds0 = new DataSourceProperties("ds_0");
+        DataSourceProperties ds0 = new DataSourceProperties("ds_0", 
createProperties());
         ds0.getCustomPoolProps().put("test", "test");
-        ds0.getProps().put("readOnly", true);
         result.put("ds_0", ds0);
         return result;
     }
+    
+    private Map<String, Object> createProperties() {
+        Map<String, Object> result = new LinkedHashMap<>(1, 1);
+        result.put("readOnly", true);
+        return result;
+    }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/config/resource/ProxyResourceConfigurationConverter.java
 
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/config/resource/ProxyResourceConfigurationConverter.java
index d5f9aff..3394f98 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/config/resource/ProxyResourceConfigurationConverter.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/config/resource/ProxyResourceConfigurationConverter.java
@@ -65,19 +65,24 @@ public final class ProxyResourceConfigurationConverter {
     }
     
     private static DataSourceProperties createDataSourceConfiguration(final 
ProxyResourceConfiguration resourceConfig) {
-        DataSourceProperties result = new 
DataSourceProperties(HikariDataSource.class.getName());
-        result.getProps().put("jdbcUrl", 
resourceConfig.getConnection().getUrl());
-        result.getProps().put("username", 
resourceConfig.getConnection().getUsername());
-        result.getProps().put("password", 
resourceConfig.getConnection().getPassword());
-        result.getProps().put("connectionTimeout", 
resourceConfig.getPool().getConnectionTimeoutMilliseconds());
-        result.getProps().put("idleTimeout", 
resourceConfig.getPool().getIdleTimeoutMilliseconds());
-        result.getProps().put("maxLifetime", 
resourceConfig.getPool().getMaxLifetimeMilliseconds());
-        result.getProps().put("maximumPoolSize", 
resourceConfig.getPool().getMaxPoolSize());
-        result.getProps().put("minimumIdle", 
resourceConfig.getPool().getMinPoolSize());
-        result.getProps().put("readOnly", 
resourceConfig.getPool().getReadOnly());
+        DataSourceProperties result = new 
DataSourceProperties(HikariDataSource.class.getName(), 
createProperties(resourceConfig));
         if (null != resourceConfig.getPool().getCustomProperties()) {
             
result.getCustomPoolProps().putAll(resourceConfig.getPool().getCustomProperties());
         }
         return result;
     }
+    
+    private static Map<String, Object> createProperties(final 
ProxyResourceConfiguration resourceConfig) {
+        Map<String, Object> result = new LinkedHashMap<>();
+        result.put("jdbcUrl", resourceConfig.getConnection().getUrl());
+        result.put("username", resourceConfig.getConnection().getUsername());
+        result.put("password", resourceConfig.getConnection().getPassword());
+        result.put("connectionTimeout", 
resourceConfig.getPool().getConnectionTimeoutMilliseconds());
+        result.put("idleTimeout", 
resourceConfig.getPool().getIdleTimeoutMilliseconds());
+        result.put("maxLifetime", 
resourceConfig.getPool().getMaxLifetimeMilliseconds());
+        result.put("maximumPoolSize", 
resourceConfig.getPool().getMaxPoolSize());
+        result.put("minimumIdle", resourceConfig.getPool().getMinPoolSize());
+        result.put("readOnly", resourceConfig.getPool().getReadOnly());
+        return result;
+    }
 }

Reply via email to