You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/01/02 13:11:15 UTC

[shardingsphere] branch master updated: Remove useless DataSourceParameter build in ResourceSegmentsConverter (#14484)

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

jianglongtao 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 700040b  Remove useless DataSourceParameter build in ResourceSegmentsConverter (#14484)
700040b is described below

commit 700040b228f0de60062f2cdbc3469b4b8e414e78
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jan 2 21:10:30 2022 +0800

    Remove useless DataSourceParameter build in ResourceSegmentsConverter (#14484)
---
 .../distsql/rdl/resource/ResourceSegmentsConverter.java   | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

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 ce70648..77f3bde 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
@@ -45,18 +45,13 @@ public final class ResourceSegmentsConverter {
     public static Map<String, DataSourceConfiguration> convert(final DatabaseType databaseType, final Collection<DataSourceSegment> resources) {
         Map<String, DataSourceConfiguration> result = new LinkedHashMap<>(resources.size(), 1);
         for (DataSourceSegment each : resources) {
-            DataSourceParameter dataSource = new DataSourceParameter();
-            dataSource.setUrl(getURL(databaseType, each));
-            dataSource.setUsername(each.getUser());
-            dataSource.setPassword(each.getPassword());
-            dataSource.setCustomPoolProps(each.getProperties());
             result.put(each.getName(), createDataSourceConfiguration(databaseType, each));
         }
         return result;
     }
     
     private static DataSourceConfiguration createDataSourceConfiguration(final DatabaseType databaseType, final DataSourceSegment segment) {
-        DataSourceConfiguration result = new DataSourceConfiguration(HikariDataSource.class.getName());
+        DataSourceConfiguration result = new DataSourceConfiguration(HikariDataSource.class.getCanonicalName());
         result.getProps().put("jdbcUrl", getURL(databaseType, segment));
         result.getProps().put("username", segment.getUser());
         result.getProps().put("password", segment.getPassword());
@@ -72,10 +67,10 @@ public final class ResourceSegmentsConverter {
         return result;
     }
     
-    private static String getURL(final DatabaseType databaseType, final DataSourceSegment dataSourceSegment) {
-        if (null != dataSourceSegment.getUrl()) {
-            return dataSourceSegment.getUrl();
+    private static String getURL(final DatabaseType databaseType, final DataSourceSegment segment) {
+        if (null != segment.getUrl()) {
+            return segment.getUrl();
         }
-        return String.format("%s//%s:%s/%s", databaseType.getJdbcUrlPrefixes().iterator().next(), dataSourceSegment.getHostName(), dataSourceSegment.getPort(), dataSourceSegment.getDb());
+        return String.format("%s//%s:%s/%s", databaseType.getJdbcUrlPrefixes().iterator().next(), segment.getHostName(), segment.getPort(), segment.getDb());
     }
 }