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


##########
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:
   Too many cast here, can we simplify it?



-- 
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