You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/07/18 04:49:44 UTC

[GitHub] [shardingsphere] yx9o commented on a diff in pull request #19312: Split DataSourceSegment to URL based and hostname+port based.

yx9o commented on code in PR #19312:
URL: https://github.com/apache/shardingsphere/pull/19312#discussion_r922969477


##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/ResourceSegmentsConverter.java:
##########
@@ -55,16 +57,21 @@ private static Map<String, Object> createProperties(final DatabaseType databaseT
         result.put("jdbcUrl", getURL(databaseType, segment));
         result.put("username", segment.getUser());
         result.put("password", segment.getPassword());
-        if (null != segment.getProperties()) {
-            result.putAll((Map) segment.getProperties());
+        if (null != segment.getProps()) {
+            result.putAll((Map) segment.getProps());
         }
         return result;
     }
     
     private static String getURL(final DatabaseType databaseType, final DataSourceSegment segment) {
-        if (null != segment.getUrl()) {
-            return segment.getUrl();
+        String result = null;
+        if (segment instanceof URLBasedDataSourceSegment) {
+            result = ((URLBasedDataSourceSegment) segment).getUrl();
         }
-        return String.format("%s//%s:%s/%s", databaseType.getJdbcUrlPrefixes().iterator().next(), segment.getHostname(), segment.getPort(), segment.getDatabase());
+        if (segment instanceof HostnameAndPortBasedDataSourceSegment) {
+            result = String.format("%s//%s:%s/%s", databaseType.getJdbcUrlPrefixes().iterator().next(), ((HostnameAndPortBasedDataSourceSegment) segment).getHostname(),

Review Comment:
   The adjustment has been completed, please review, thank you.



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org