This is an automated email from the ASF dual-hosted git repository.
totalo 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 890accf97e9 Remove useless NamedRuleItemNodePath.isValidatedPath()
(#26596)
890accf97e9 is described below
commit 890accf97e9d7410105d6b9f4c788b0010abb089
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jun 27 01:18:26 2023 +0800
Remove useless NamedRuleItemNodePath.isValidatedPath() (#26596)
---
...lCompatibleEncryptRuleConfigurationSwapper.java | 11 +++----
.../NewYamlEncryptRuleConfigurationSwapper.java | 11 +++----
.../NewYamlMaskRuleConfigurationSwapper.java | 11 +++----
...ReadwriteSplittingRuleConfigurationSwapper.java | 11 +++----
.../NewYamlShadowRuleConfigurationSwapper.java | 18 +++++-------
.../NewYamlShardingRuleConfigurationSwapper.java | 34 +++++++++-------------
.../infra/metadata/nodepath/RuleRootNodePath.java | 4 +--
.../nodepath/item/NamedRuleItemNodePath.java | 17 ++---------
.../nodepath/item/UniqueRuleItemNodePath.java | 8 ++---
.../metadata/nodepath/RuleRootNodePathTest.java | 2 +-
.../nodepath/item/NamedRuleItemNodePathTest.java | 15 ++++------
11 files changed, 50 insertions(+), 92 deletions(-)
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapper.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapper.java
index 856e6bdcbcf..f03c140d676 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapper.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapper.java
@@ -68,13 +68,10 @@ public final class
NewYamlCompatibleEncryptRuleConfigurationSwapper implements N
Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> encryptors = new HashMap<>();
for (YamlDataNode each : dataNodes) {
- if
(CompatibleEncryptNodeConverter.getTableNodePath().isValidatedPath(each.getKey()))
{
-
CompatibleEncryptNodeConverter.getTableNodePath().getName(each.getKey())
- .ifPresent(tableName ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlCompatibleEncryptTableRuleConfiguration.class))));
- } else if
(CompatibleEncryptNodeConverter.getEncryptorNodePath().isValidatedPath(each.getKey()))
{
-
CompatibleEncryptNodeConverter.getEncryptorNodePath().getName(each.getKey())
- .ifPresent(encryptorName ->
encryptors.put(encryptorName,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- }
+
CompatibleEncryptNodeConverter.getTableNodePath().getName(each.getKey())
+ .ifPresent(optional ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlCompatibleEncryptTableRuleConfiguration.class))));
+
CompatibleEncryptNodeConverter.getEncryptorNodePath().getName(each.getKey())
+ .ifPresent(optional -> encryptors.put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
}
return new CompatibleEncryptRuleConfiguration(tables, encryptors);
}
diff --git
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapper.java
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapper.java
index cf336ffc8cd..c9071e7adf5 100644
---
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapper.java
+++
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapper.java
@@ -65,13 +65,10 @@ public final class NewYamlEncryptRuleConfigurationSwapper
implements NewYamlRule
Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> encryptors = new HashMap<>();
for (YamlDataNode each : dataNodes) {
- if
(EncryptNodeConverter.getTableNodePath().isValidatedPath(each.getKey())) {
- EncryptNodeConverter.getTableNodePath().getName(each.getKey())
- .ifPresent(tableName ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlEncryptTableRuleConfiguration.class))));
- } else if
(EncryptNodeConverter.getEncryptorNodePath().isValidatedPath(each.getKey())) {
-
EncryptNodeConverter.getEncryptorNodePath().getName(each.getKey())
- .ifPresent(encryptorName ->
encryptors.put(encryptorName,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- }
+ EncryptNodeConverter.getTableNodePath().getName(each.getKey())
+ .ifPresent(optional ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlEncryptTableRuleConfiguration.class))));
+ EncryptNodeConverter.getEncryptorNodePath().getName(each.getKey())
+ .ifPresent(optional -> encryptors.put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
}
return new EncryptRuleConfiguration(tables, encryptors);
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
index a188e1994fd..e9360e91372 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapper.java
@@ -63,13 +63,10 @@ public final class NewYamlMaskRuleConfigurationSwapper
implements NewYamlRuleCon
Collection<MaskTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> algorithms = new LinkedHashMap<>();
for (YamlDataNode each : dataNodes) {
- if
(MaskNodeConverter.getTableNodePath().isValidatedPath(each.getKey())) {
- MaskNodeConverter.getTableNodePath().getName(each.getKey())
- .ifPresent(tableName ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlMaskTableRuleConfiguration.class))));
- } else if
(MaskNodeConverter.getAlgorithmNodePath().isValidatedPath(each.getKey())) {
- MaskNodeConverter.getAlgorithmNodePath().getName(each.getKey())
- .ifPresent(loadBalancerName ->
algorithms.put(loadBalancerName,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- }
+ MaskNodeConverter.getTableNodePath().getName(each.getKey())
+ .ifPresent(optional ->
tables.add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlMaskTableRuleConfiguration.class))));
+ MaskNodeConverter.getAlgorithmNodePath().getName(each.getKey())
+ .ifPresent(optional -> algorithms.put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
}
return new MaskRuleConfiguration(tables, algorithms);
}
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
index bff25d06082..a681df41a08 100644
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
+++
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapper.java
@@ -72,13 +72,10 @@ public final class
NewYamlReadwriteSplittingRuleConfigurationSwapper implements
Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources
= new LinkedList<>();
Map<String, AlgorithmConfiguration> loadBalancerMap = new
LinkedHashMap<>();
for (YamlDataNode each : dataNodes) {
- if
(ReadwriteSplittingNodeConverter.getDataSourceNodePath().isValidatedPath(each.getKey()))
{
-
ReadwriteSplittingNodeConverter.getDataSourceNodePath().getName(each.getKey())
- .ifPresent(groupName ->
dataSources.add(swapDataSource(groupName, YamlEngine.unmarshal(each.getValue(),
YamlReadwriteSplittingDataSourceRuleConfiguration.class))));
- } else if
(ReadwriteSplittingNodeConverter.getLoadBalancerNodePath().isValidatedPath(each.getKey()))
{
-
ReadwriteSplittingNodeConverter.getLoadBalancerNodePath().getName(each.getKey())
- .ifPresent(loadBalancerName ->
loadBalancerMap.put(loadBalancerName,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- }
+
ReadwriteSplittingNodeConverter.getDataSourceNodePath().getName(each.getKey())
+ .ifPresent(optional ->
dataSources.add(swapDataSource(optional, YamlEngine.unmarshal(each.getValue(),
YamlReadwriteSplittingDataSourceRuleConfiguration.class))));
+
ReadwriteSplittingNodeConverter.getLoadBalancerNodePath().getName(each.getKey())
+ .ifPresent(optional -> loadBalancerMap.put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
}
return new ReadwriteSplittingRuleConfiguration(dataSources,
loadBalancerMap);
}
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapper.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapper.java
index 492bd72d122..53844083df8 100644
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapper.java
+++
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapper.java
@@ -76,17 +76,13 @@ public final class NewYamlShadowRuleConfigurationSwapper
implements NewYamlRuleC
public ShadowRuleConfiguration swapToObject(final Collection<YamlDataNode>
dataNodes) {
ShadowRuleConfiguration result = new ShadowRuleConfiguration();
for (YamlDataNode each : dataNodes) {
- if
(ShadowNodeConverter.getDataSourceNodePath().isValidatedPath(each.getKey())) {
-
ShadowNodeConverter.getDataSourceNodePath().getName(each.getKey())
- .ifPresent(dataSourceName ->
result.getDataSources().add(swapDataSource(dataSourceName,
YamlEngine.unmarshal(each.getValue(),
YamlShadowDataSourceConfiguration.class))));
- } else if
(ShadowNodeConverter.getTableNodePath().isValidatedPath(each.getKey())) {
- ShadowNodeConverter.getTableNodePath().getName(each.getKey())
- .ifPresent(tableName ->
result.getTables().put(tableName,
tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShadowTableConfiguration.class))));
- } else if
(ShadowNodeConverter.getAlgorithmNodePath().isValidatedPath(each.getKey())) {
-
ShadowNodeConverter.getAlgorithmNodePath().getName(each.getKey())
- .ifPresent(algorithmName ->
result.getShadowAlgorithms().put(algorithmName,
-
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- } else if
(ShadowNodeConverter.getDefaultAlgorithmNameNodePath().isValidatedPath(each.getKey()))
{
+ ShadowNodeConverter.getDataSourceNodePath().getName(each.getKey())
+ .ifPresent(optional ->
result.getDataSources().add(swapDataSource(optional,
YamlEngine.unmarshal(each.getValue(),
YamlShadowDataSourceConfiguration.class))));
+ ShadowNodeConverter.getTableNodePath().getName(each.getKey())
+ .ifPresent(optional -> result.getTables().put(optional,
tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShadowTableConfiguration.class))));
+ ShadowNodeConverter.getAlgorithmNodePath().getName(each.getKey())
+ .ifPresent(optional ->
result.getShadowAlgorithms().put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
+ if
(ShadowNodeConverter.getDefaultAlgorithmNameNodePath().isValidatedPath(each.getKey()))
{
result.setDefaultShadowAlgorithmName(each.getValue());
}
}
diff --git
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
index e99114d714e..5eee2f0b95e 100644
---
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
+++
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapper.java
@@ -132,16 +132,19 @@ public final class
NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
public ShardingRuleConfiguration swapToObject(final
Collection<YamlDataNode> dataNodes) {
ShardingRuleConfiguration result = new ShardingRuleConfiguration();
for (YamlDataNode each : dataNodes) {
- if
(ShardingNodeConverter.getTableNodePath().isValidatedPath(each.getKey())) {
- ShardingNodeConverter.getTableNodePath().getName(each.getKey())
- .ifPresent(tableName ->
result.getTables().add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlTableRuleConfiguration.class))));
- } else if
(ShardingNodeConverter.getAutoTableNodePath().isValidatedPath(each.getKey())) {
-
ShardingNodeConverter.getAutoTableNodePath().getName(each.getKey())
- .ifPresent(autoTableName ->
result.getAutoTables().add(autoTableYamlSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingAutoTableRuleConfiguration.class))));
- } else if
(ShardingNodeConverter.getBindingTableNodePath().isValidatedPath(each.getKey()))
{
-
ShardingNodeConverter.getBindingTableNodePath().getName(each.getKey())
- .ifPresent(bindingTableName ->
result.getBindingTableGroups().add(YamlShardingTableReferenceRuleConfigurationConverter.convertToObject(each.getValue())));
- } else if
(ShardingNodeConverter.getDefaultDatabaseStrategyNodePath().isValidatedPath(each.getKey()))
{
+ ShardingNodeConverter.getTableNodePath().getName(each.getKey())
+ .ifPresent(optional ->
result.getTables().add(tableSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlTableRuleConfiguration.class))));
+ ShardingNodeConverter.getAutoTableNodePath().getName(each.getKey())
+ .ifPresent(optional ->
result.getAutoTables().add(autoTableYamlSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingAutoTableRuleConfiguration.class))));
+
ShardingNodeConverter.getBindingTableNodePath().getName(each.getKey())
+ .ifPresent(optional ->
result.getBindingTableGroups().add(YamlShardingTableReferenceRuleConfigurationConverter.convertToObject(each.getValue())));
+ ShardingNodeConverter.getAlgorithmNodePath().getName(each.getKey())
+ .ifPresent(optional ->
result.getShardingAlgorithms().put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
+
ShardingNodeConverter.getKeyGeneratorNodePath().getName(each.getKey())
+ .ifPresent(optional ->
result.getKeyGenerators().put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
+ ShardingNodeConverter.getAuditorNodePath().getName(each.getKey())
+ .ifPresent(optional -> result.getAuditors().put(optional,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
+ if
(ShardingNodeConverter.getDefaultDatabaseStrategyNodePath().isValidatedPath(each.getKey()))
{
result.setDefaultDatabaseShardingStrategy(shardingStrategySwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingStrategyConfiguration.class)));
} else if
(ShardingNodeConverter.getDefaultTableStrategyNodePath().isValidatedPath(each.getKey()))
{
result.setDefaultTableShardingStrategy(shardingStrategySwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingStrategyConfiguration.class)));
@@ -151,17 +154,6 @@ public final class NewYamlShardingRuleConfigurationSwapper
implements NewYamlRul
result.setDefaultAuditStrategy(auditStrategySwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingAuditStrategyConfiguration.class)));
} else if
(ShardingNodeConverter.getDefaultShardingColumnNodePath().isValidatedPath(each.getKey()))
{
result.setDefaultShardingColumn(each.getValue());
- } else if
(ShardingNodeConverter.getAlgorithmNodePath().isValidatedPath(each.getKey())) {
-
ShardingNodeConverter.getAlgorithmNodePath().getName(each.getKey())
- .ifPresent(algorithmName ->
result.getShardingAlgorithms().put(algorithmName,
-
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- } else if
(ShardingNodeConverter.getKeyGeneratorNodePath().isValidatedPath(each.getKey()))
{
-
ShardingNodeConverter.getKeyGeneratorNodePath().getName(each.getKey())
- .ifPresent(keyGeneratorName ->
result.getKeyGenerators().put(keyGeneratorName,
-
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
- } else if
(ShardingNodeConverter.getAuditorNodePath().isValidatedPath(each.getKey())) {
-
ShardingNodeConverter.getAuditorNodePath().getName(each.getKey())
- .ifPresent(auditorName ->
result.getAuditors().put(auditorName,
algorithmSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlAlgorithmConfiguration.class))));
} else if
(ShardingNodeConverter.getShardingCacheNodePath().isValidatedPath(each.getKey()))
{
result.setShardingCache(shardingCacheYamlSwapper.swapToObject(YamlEngine.unmarshal(each.getValue(),
YamlShardingCacheConfiguration.class)));
}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleRootNodePath.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleRootNodePath.java
index b9392be79cd..d4ed7cf33f0 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleRootNodePath.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleRootNodePath.java
@@ -34,8 +34,8 @@ public final class RuleRootNodePath {
private final Pattern pathPattern;
public RuleRootNodePath(final String ruleType) {
- nodePrefix = RULE_NODE_PREFIX + ruleType;
- pathPattern = Pattern.compile(nodePrefix + "/.*");
+ nodePrefix = RULE_NODE_PREFIX + ruleType + "/";
+ pathPattern = Pattern.compile(nodePrefix + ".*");
}
/**
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/item/NamedRuleItemNodePath.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/item/NamedRuleItemNodePath.java
index e203baae2c9..6dbc4a2c8a0 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/item/NamedRuleItemNodePath.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/item/NamedRuleItemNodePath.java
@@ -34,17 +34,14 @@ public final class NamedRuleItemNodePath {
private final String type;
- private final Pattern pathPattern;
-
private final Pattern namePathPattern;
private final Pattern activeVersionPathPattern;
public NamedRuleItemNodePath(final RuleRootNodePath rootNodePath, final
String type) {
this.type = type;
- pathPattern = Pattern.compile(rootNodePath.getNodePrefix() + "/" +
type + "/.*");
- namePathPattern = Pattern.compile(rootNodePath.getNodePrefix() + "/" +
type + NAME);
- activeVersionPathPattern =
Pattern.compile(rootNodePath.getNodePrefix() + "/" + type + ACTIVE_VERSION);
+ namePathPattern = Pattern.compile(rootNodePath.getNodePrefix() + type
+ NAME);
+ activeVersionPathPattern =
Pattern.compile(rootNodePath.getNodePrefix() + type + ACTIVE_VERSION);
}
/**
@@ -57,16 +54,6 @@ public final class NamedRuleItemNodePath {
return String.join("/", type, itemName);
}
- /**
- * Judge whether is validated rule item path.
- *
- * @param path path to be judged
- * @return is validated rule item path or not
- */
- public boolean isValidatedPath(final String path) {
- return pathPattern.matcher(path).find();
- }
-
/**
* Get rule item name.
*
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/item/UniqueRuleItemNodePath.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/item/UniqueRuleItemNodePath.java
index 8045e1a17a0..f3f0a460da4 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/item/UniqueRuleItemNodePath.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/nodepath/item/UniqueRuleItemNodePath.java
@@ -42,15 +42,15 @@ public final class UniqueRuleItemNodePath {
public UniqueRuleItemNodePath(final RuleRootNodePath ruleRootNodePath,
final String type) {
parentNode = null;
this.type = type;
- pathPattern = Pattern.compile(ruleRootNodePath.getNodePrefix() + "/" +
type + VERSIONS);
- activeVersionPathPattern =
Pattern.compile(ruleRootNodePath.getNodePrefix() + "/" + type + ACTIVE_VERSION);
+ pathPattern = Pattern.compile(ruleRootNodePath.getNodePrefix() + type
+ VERSIONS);
+ activeVersionPathPattern =
Pattern.compile(ruleRootNodePath.getNodePrefix() + type + ACTIVE_VERSION);
}
public UniqueRuleItemNodePath(final RuleRootNodePath ruleRootNodePath,
final String parentNode, final String type) {
this.parentNode = parentNode;
this.type = type;
- pathPattern = Pattern.compile(ruleRootNodePath.getNodePrefix() + "/" +
parentNode + "/" + type + VERSIONS);
- activeVersionPathPattern =
Pattern.compile(ruleRootNodePath.getNodePrefix() + "/" + parentNode + "/" +
type + ACTIVE_VERSION);
+ pathPattern = Pattern.compile(ruleRootNodePath.getNodePrefix() +
parentNode + "/" + type + VERSIONS);
+ activeVersionPathPattern =
Pattern.compile(ruleRootNodePath.getNodePrefix() + parentNode + "/" + type +
ACTIVE_VERSION);
}
/**
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleRootNodePathTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleRootNodePathTest.java
index 6b5789d15b1..8f494b59f82 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleRootNodePathTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/nodepath/RuleRootNodePathTest.java
@@ -30,7 +30,7 @@ class RuleRootNodePathTest {
@Test
void assertGetRuleNodePrefix() {
- assertThat(nodePath.getNodePrefix(),
is("/[\\w\\-]+/[\\w\\-]+/rules/foo"));
+ assertThat(nodePath.getNodePrefix(),
is("/[\\w\\-]+/[\\w\\-]+/rules/foo/"));
}
@Test
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/nodepath/item/NamedRuleItemNodePathTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/nodepath/item/NamedRuleItemNodePathTest.java
index 1fae062c8ab..5bb5f65a7b9 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/nodepath/item/NamedRuleItemNodePathTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/nodepath/item/NamedRuleItemNodePathTest.java
@@ -36,16 +36,6 @@ class NamedRuleItemNodePathTest {
assertThat(converter.getPath("foo_table"), is("tables/foo_table"));
}
- @Test
- void assertIsValidatedPath() {
-
assertTrue(converter.isValidatedPath("/metadata/foo_db/rules/foo/tables/foo_table/versions/0"));
- }
-
- @Test
- void assertIsNotValidatedPath() {
-
assertFalse(converter.isValidatedPath("/metadata/foo_db/rules/bar/tables/foo_table/versions/0"));
- }
-
@Test
void assertGetName() {
Optional<String> actual =
converter.getName("/metadata/foo_db/rules/foo/tables/foo_table/versions/0");
@@ -53,6 +43,11 @@ class NamedRuleItemNodePathTest {
assertThat(actual.get(), is("foo_table"));
}
+ @Test
+ void assertGetNameWithInvalidPath() {
+
assertFalse(converter.getName("/metadata/foo_db/rules/bar/tables/foo_table/versions/0").isPresent());
+ }
+
@Test
void assertGetNameByActiveVersionPath() {
Optional<String> actual =
converter.getNameByActiveVersion("/metadata/foo_db/rules/foo/tables/foo_table/active_version");