You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2023/07/27 07:46:43 UTC

[shardingsphere] branch master updated: Fix sonar issue on OracleConnectionPropertiesParser (#27507)

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

sunnianjun 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 f1be57de665 Fix sonar issue on OracleConnectionPropertiesParser (#27507)
f1be57de665 is described below

commit f1be57de665727537788c9182df9b3be37f6c4f3
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jul 27 15:46:34 2023 +0800

    Fix sonar issue on OracleConnectionPropertiesParser (#27507)
---
 .../database/oracle/OracleConnectionPropertiesParser.java    | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/infra/database/type/oracle/src/main/java/org/apache/shardingsphere/infra/database/oracle/OracleConnectionPropertiesParser.java b/infra/database/type/oracle/src/main/java/org/apache/shardingsphere/infra/database/oracle/OracleConnectionPropertiesParser.java
index 0852f10e079..06f387bf80f 100644
--- a/infra/database/type/oracle/src/main/java/org/apache/shardingsphere/infra/database/oracle/OracleConnectionPropertiesParser.java
+++ b/infra/database/type/oracle/src/main/java/org/apache/shardingsphere/infra/database/oracle/OracleConnectionPropertiesParser.java
@@ -47,9 +47,15 @@ public final class OracleConnectionPropertiesParser implements ConnectionPropert
         List<Matcher> matchers = Arrays.asList(THIN_URL_PATTERN.matcher(url), CONNECT_DESCRIPTOR_URL_PATTERN.matcher(url));
         Matcher matcher = matchers.stream().filter(Matcher::find).findAny().orElseThrow(() -> new UnrecognizedDatabaseURLException(url, THIN_URL_PATTERN.pattern()));
         int groupCount = matcher.groupCount();
-        return THIN_MATCH_GROUP_COUNT == groupCount
-                ? new StandardConnectionProperties(matcher.group(3), Strings.isNullOrEmpty(matcher.group(4)) ? DEFAULT_PORT : Integer.parseInt(matcher.group(4)), matcher.group(5), username)
-                : new StandardConnectionProperties(matcher.group(2), Strings.isNullOrEmpty(matcher.group(3)) ? DEFAULT_PORT : Integer.parseInt(matcher.group(3)), matcher.group(4), username);
+        return THIN_MATCH_GROUP_COUNT == groupCount ? getThinConnectionProperties(username, matcher) : getStandardConnectionProperties(username, matcher);
+    }
+    
+    private StandardConnectionProperties getThinConnectionProperties(final String username, final Matcher matcher) {
+        return new StandardConnectionProperties(matcher.group(3), Strings.isNullOrEmpty(matcher.group(4)) ? DEFAULT_PORT : Integer.parseInt(matcher.group(4)), matcher.group(5), username);
+    }
+    
+    private StandardConnectionProperties getStandardConnectionProperties(final String username, final Matcher matcher) {
+        return new StandardConnectionProperties(matcher.group(2), Strings.isNullOrEmpty(matcher.group(3)) ? DEFAULT_PORT : Integer.parseInt(matcher.group(3)), matcher.group(4), username);
     }
     
     @Override