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

menghaoran 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 bf2d065b2cc Refactor NodePathSearcher (#34802)
bf2d065b2cc is described below

commit bf2d065b2cc13cc7a2c615dd15f0e7bd5e840242
Author: Haoran Meng <menghaora...@gmail.com>
AuthorDate: Thu Feb 27 14:06:55 2025 +0800

    Refactor NodePathSearcher (#34802)
---
 .../mode/node/path/engine/searcher/NodePathSearcher.java              | 4 +++-
 .../test/it/yaml/YamlRuleRepositoryTupleSwapperEngineIT.java          | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/engine/searcher/NodePathSearcher.java
 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/engine/searcher/NodePathSearcher.java
index a338d11c810..efab306f0e6 100644
--- 
a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/engine/searcher/NodePathSearcher.java
+++ 
b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/engine/searcher/NodePathSearcher.java
@@ -32,6 +32,8 @@ import java.util.regex.Pattern;
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class NodePathSearcher {
     
+    private static final String START_PATTERN = "^";
+    
     /**
      * Find node segment.
      *
@@ -57,6 +59,6 @@ public final class NodePathSearcher {
     
     private static Pattern createPattern(final NodePath nodePathCriteria, 
final boolean trimEmptyNode, final boolean containsChildPath) {
         String endPattern = containsChildPath ? "?" : "$";
-        return Pattern.compile(NodePathGenerator.toPath(nodePathCriteria, 
trimEmptyNode) + endPattern, Pattern.CASE_INSENSITIVE);
+        return Pattern.compile(START_PATTERN + 
NodePathGenerator.toPath(nodePathCriteria, trimEmptyNode) + endPattern, 
Pattern.CASE_INSENSITIVE);
     }
 }
diff --git 
a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleRepositoryTupleSwapperEngineIT.java
 
b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleRepositoryTupleSwapperEngineIT.java
index eac00e8513d..70a27f84323 100644
--- 
a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleRepositoryTupleSwapperEngineIT.java
+++ 
b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleRepositoryTupleSwapperEngineIT.java
@@ -105,7 +105,7 @@ public abstract class 
YamlRuleRepositoryTupleSwapperEngineIT {
     }
     
     private String getRepositoryTupleKey(final boolean isGlobalRule, final 
String ruleType, final RuleRepositoryTuple tuple) {
-        return isGlobalRule ? String.format("/metadata/rules/%s/versions/0", 
ruleType) : String.format("/metadata/foo_db/rules/%s/%s/versions/0", ruleType, 
tuple.getKey());
+        return isGlobalRule ? String.format("/rules/%s/versions/0", ruleType) 
: String.format("/metadata/foo_db/rules/%s/%s/versions/0", ruleType, 
tuple.getKey());
     }
     
     private String getExpectedYamlContent() throws IOException {

Reply via email to