You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/02/12 15:31:06 UTC

(shardingsphere) branch master updated: Refactor RuleRootNodePath (#34649)

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

zhangliang 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 b8c413033e5 Refactor RuleRootNodePath (#34649)
b8c413033e5 is described below

commit b8c413033e556ae9318d3192809f8851f6e332a7
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed Feb 12 23:30:59 2025 +0800

    Refactor RuleRootNodePath (#34649)
---
 .../mode/node/path/config/database/root/RuleRootNodePath.java       | 6 ++++--
 .../mode/node/path/config/database/root/RuleRootNodePathTest.java   | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/root/RuleRootNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/root/RuleRootNodePath.java
index aa49fd21f8e..8ab8437d437 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/root/RuleRootNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/database/root/RuleRootNodePath.java
@@ -26,7 +26,9 @@ import java.util.regex.Pattern;
  */
 public final class RuleRootNodePath {
     
-    private static final String RULE_NODE_PREFIX = "/[\\w\\-]+/[\\w\\-]+/rules/";
+    private static final String ROOT_NODE = "/metadata";
+    
+    private static final String RULE_NODE = "rules";
     
     @Getter
     private final String ruleType;
@@ -38,7 +40,7 @@ public final class RuleRootNodePath {
     
     public RuleRootNodePath(final String ruleType) {
         this.ruleType = ruleType;
-        nodePrefix = RULE_NODE_PREFIX + ruleType + "/";
+        nodePrefix = String.join("/", ROOT_NODE, "[\\w\\-]+", RULE_NODE, ruleType, "");
         pathPattern = Pattern.compile(nodePrefix + ".*");
     }
     
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/database/root/RuleRootNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/database/root/RuleRootNodePathTest.java
index 5685e117856..9a5ffe5e7d7 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/database/root/RuleRootNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/database/root/RuleRootNodePathTest.java
@@ -30,7 +30,7 @@ class RuleRootNodePathTest {
     
     @Test
     void assertGetRuleNodePrefix() {
-        assertThat(nodePath.getNodePrefix(), is("/[\\w\\-]+/[\\w\\-]+/rules/foo/"));
+        assertThat(nodePath.getNodePrefix(), is("/metadata/[\\w\\-]+/rules/foo/"));
     }
     
     @Test