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

zhaojinchao 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 e5454788a8b Refactor GlobalNodePath (#30642)
e5454788a8b is described below

commit e5454788a8b8abd8cd6d26c61e4c63cd0b4bfe95
Author: zhaojinchao <[email protected]>
AuthorDate: Mon Mar 25 22:00:07 2024 +0800

    Refactor GlobalNodePath (#30642)
---
 .../shardingsphere/infra/config/nodepath/GlobalNodePath.java      | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/nodepath/GlobalNodePath.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/nodepath/GlobalNodePath.java
index f708eba6594..3d6060d4d40 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/nodepath/GlobalNodePath.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/nodepath/GlobalNodePath.java
@@ -36,6 +36,8 @@ public final class GlobalNodePath {
     
     private static final String VERSIONS = "versions";
     
+    private static final String ACTIVE_VERSION_SUFFIX = "/active_version$";
+    
     /**
      * Get version.
      *
@@ -60,7 +62,7 @@ public final class GlobalNodePath {
      * @return true or false
      */
     public static boolean isRuleActiveVersionPath(final String rulePath) {
-        Pattern pattern = Pattern.compile(getRuleNameNode() + 
"/(\\w+)/active_version$", Pattern.CASE_INSENSITIVE);
+        Pattern pattern = Pattern.compile(getRuleNameNode() + "/(\\w+)" + 
ACTIVE_VERSION_SUFFIX, Pattern.CASE_INSENSITIVE);
         Matcher matcher = pattern.matcher(rulePath);
         return matcher.find();
     }
@@ -72,7 +74,7 @@ public final class GlobalNodePath {
      * @return true or false
      */
     public static boolean isPropsActiveVersionPath(final String propsPath) {
-        Pattern pattern = Pattern.compile(getPropsNode() + "/active_version$", 
Pattern.CASE_INSENSITIVE);
+        Pattern pattern = Pattern.compile(getPropsNode() + 
ACTIVE_VERSION_SUFFIX, Pattern.CASE_INSENSITIVE);
         Matcher matcher = pattern.matcher(propsPath);
         return matcher.find();
     }
@@ -88,7 +90,7 @@ public final class GlobalNodePath {
      * @return rule name
      */
     public static Optional<String> getRuleName(final String rulePath) {
-        Pattern pattern = Pattern.compile(getRuleNameNode() + 
"/(\\w+)/active_version$", Pattern.CASE_INSENSITIVE);
+        Pattern pattern = Pattern.compile(getRuleNameNode() + "/(\\w+)" + 
ACTIVE_VERSION_SUFFIX, Pattern.CASE_INSENSITIVE);
         Matcher matcher = pattern.matcher(rulePath);
         return matcher.find() ? Optional.of(matcher.group(1)) : 
Optional.empty();
     }

Reply via email to