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 2023/06/27 06:09:49 UTC
[shardingsphere] branch master updated: Refactor encrypt & mask rule changed subscriber (#26608)
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 7e71f37877a Refactor encrypt & mask rule changed subscriber (#26608)
7e71f37877a is described below
commit 7e71f37877ab3d55bfec327b53b74d33868dbd24
Author: ChenJiaHao <Pa...@163.com>
AuthorDate: Tue Jun 27 14:09:34 2023 +0800
Refactor encrypt & mask rule changed subscriber (#26608)
* Refactor encrypt rule changed subscriber
* Use LinkedHashMap
* Refactor mask rule changed subscriber
---
.../NewYamlBroadcastRuleConfigurationSwapper.java | 4 ++
...wYamlBroadcastRuleConfigurationSwapperTest.java | 3 +-
.../encrypt/subscriber/EncryptTableSubscriber.java | 28 +++++++++-----
.../encrypt/subscriber/EncryptorSubscriber.java | 23 +++++++++--
.../CompatibleEncryptTableSubscriber.java | 28 +++++++++-----
.../compatible/CompatibleEncryptorSubscriber.java | 23 +++++++++--
...lCompatibleEncryptRuleConfigurationSwapper.java | 4 ++
.../NewYamlEncryptRuleConfigurationSwapper.java | 3 ++
...patibleEncryptRuleConfigurationSwapperTest.java | 4 +-
...NewYamlEncryptRuleConfigurationSwapperTest.java | 4 +-
.../mask/subscriber/MaskAlgorithmSubscriber.java | 45 ++++++++++------------
.../mask/subscriber/MaskTableSubscriber.java | 38 ++++++++----------
.../NewYamlMaskRuleConfigurationSwapper.java | 4 ++
.../NewYamlMaskRuleConfigurationSwapperTest.java | 4 +-
...ReadwriteSplittingRuleConfigurationSwapper.java | 4 ++
...writeSplittingRuleConfigurationSwapperTest.java | 4 +-
.../NewYamlShadowRuleConfigurationSwapper.java | 4 ++
.../NewYamlShadowRuleConfigurationSwapperTest.java | 4 +-
.../NewYamlShardingRuleConfigurationSwapper.java | 4 ++
...ewYamlShardingRuleConfigurationSwapperTest.java | 13 +------
.../NewYamlRuleConfigurationSwapperEngine.java | 2 +
.../NewYamlSingleRuleConfigurationSwapper.java | 4 ++
.../test/e2e/agent/file/FilePluginE2EIT.java | 2 +-
23 files changed, 161 insertions(+), 95 deletions(-)
diff --git a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapper.java b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapper.java
index 86bd9220280..9c348c64381 100644
--- a/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapper.java
+++ b/features/broadcast/core/src/main/java/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapper.java
@@ -49,6 +49,10 @@ public final class NewYamlBroadcastRuleConfigurationSwapper implements NewYamlRu
@Override
public BroadcastRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
+ if (dataNodes.stream().noneMatch(each -> broadcastRuleNodePath.getRoot().isValidatedPath(each.getKey()))) {
+ // TODO refactor this use Optional
+ return null;
+ }
for (YamlDataNode each : dataNodes) {
if (broadcastRuleNodePath.getRoot().isValidatedPath(each.getKey())) {
YamlBroadcastRuleConfiguration yamlBroadcastRuleConfiguration = YamlEngine.unmarshal(each.getValue(), YamlBroadcastRuleConfiguration.class);
diff --git a/features/broadcast/core/src/main/test/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapperTest.java b/features/broadcast/core/src/main/test/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapperTest.java
index 5e208a9e09b..a8e7f096706 100644
--- a/features/broadcast/core/src/main/test/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapperTest.java
+++ b/features/broadcast/core/src/main/test/org/apache/shardingsphere/broadcast/yaml/swapper/NewYamlBroadcastRuleConfigurationSwapperTest.java
@@ -28,6 +28,7 @@ import java.util.LinkedList;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class NewYamlBroadcastRuleConfigurationSwapperTest {
@@ -61,7 +62,7 @@ class NewYamlBroadcastRuleConfigurationSwapperTest {
void assertSwapToObjectEmpty() {
Collection<YamlDataNode> config = new LinkedList<>();
BroadcastRuleConfiguration result = swapper.swapToObject(config);
- assertThat(result.getTables().size(), is(0));
+ assertTrue(result == null);
}
@Test
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptTableSubscriber.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptTableSubscriber.java
index 0415e1ca431..0818832680f 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptTableSubscriber.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptTableSubscriber.java
@@ -33,7 +33,8 @@ import org.apache.shardingsphere.infra.rule.RuleChangedSubscriber;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
-import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.Map;
import java.util.Optional;
@@ -61,15 +62,7 @@ public final class EncryptTableSubscriber implements RuleChangedSubscriber {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
EncryptTableRuleConfiguration needToAddedConfig = swapEncryptTableRuleConfig(
instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
- Optional<EncryptRule> rule = database.getRuleMetaData().findSingleRule(EncryptRule.class);
- EncryptRuleConfiguration config;
- if (rule.isPresent()) {
- config = (EncryptRuleConfiguration) rule.get().getConfiguration();
- config.getTables().add(needToAddedConfig);
- } else {
- config = new EncryptRuleConfiguration(Collections.singletonList(needToAddedConfig), Collections.emptyMap());
- }
- instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), getEncryptRuleConfiguration(database, needToAddedConfig)));
}
/**
@@ -110,4 +103,19 @@ public final class EncryptTableSubscriber implements RuleChangedSubscriber {
private EncryptTableRuleConfiguration swapEncryptTableRuleConfig(final String yamlContext) {
return new YamlEncryptTableRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlEncryptTableRuleConfiguration.class));
}
+
+ private EncryptRuleConfiguration getEncryptRuleConfiguration(final ShardingSphereDatabase database, final EncryptTableRuleConfiguration needToAddedConfig) {
+ Optional<EncryptRule> rule = database.getRuleMetaData().findSingleRule(EncryptRule.class);
+ EncryptRuleConfiguration config = rule.map(encryptRule -> getEncryptRuleConfiguration((EncryptRuleConfiguration) encryptRule.getConfiguration()))
+ .orElseGet(() -> new EncryptRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>()));
+ config.getTables().add(needToAddedConfig);
+ return config;
+ }
+
+ private EncryptRuleConfiguration getEncryptRuleConfiguration(final EncryptRuleConfiguration config) {
+ if (null == config.getTables()) {
+ return new EncryptRuleConfiguration(new LinkedList<>(), config.getEncryptors());
+ }
+ return config;
+ }
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptorSubscriber.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptorSubscriber.java
index 15eb7d13b8a..4ba56410530 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptorSubscriber.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/EncryptorSubscriber.java
@@ -32,7 +32,10 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmC
import org.apache.shardingsphere.infra.yaml.config.swapper.algorithm.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.Map;
+import java.util.Optional;
/**
* Encrypt encryptor subscriber.
@@ -56,9 +59,7 @@ public final class EncryptorSubscriber implements RuleChangedSubscriber {
return;
}
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- EncryptRuleConfiguration config = (EncryptRuleConfiguration) database.getRuleMetaData().getSingleRule(EncryptRule.class).getConfiguration();
- config.getEncryptors().put(event.getEncryptorName(), swapToAlgorithmConfig(
- instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), getEncryptRuleConfiguration(database, event)));
}
/**
@@ -77,6 +78,22 @@ public final class EncryptorSubscriber implements RuleChangedSubscriber {
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
+ private EncryptRuleConfiguration getEncryptRuleConfiguration(final ShardingSphereDatabase database, final AlterEncryptorEvent event) {
+ Optional<EncryptRule> rule = database.getRuleMetaData().findSingleRule(EncryptRule.class);
+ EncryptRuleConfiguration config = rule.map(encryptRule -> getEncryptRuleConfiguration((EncryptRuleConfiguration) encryptRule.getConfiguration()))
+ .orElseGet(() -> new EncryptRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>()));
+ config.getEncryptors().put(event.getEncryptorName(), swapToAlgorithmConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
+ return config;
+ }
+
+ private EncryptRuleConfiguration getEncryptRuleConfiguration(final EncryptRuleConfiguration config) {
+ if (null == config.getEncryptors()) {
+ return new EncryptRuleConfiguration(config.getTables(), new LinkedHashMap<>());
+ }
+ return config;
+ }
+
private AlgorithmConfiguration swapToAlgorithmConfig(final String yamlContext) {
return new YamlAlgorithmConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlAlgorithmConfiguration.class));
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/compatible/CompatibleEncryptTableSubscriber.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/compatible/CompatibleEncryptTableSubscriber.java
index 8fca3ccb9a6..de003002139 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/compatible/CompatibleEncryptTableSubscriber.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/compatible/CompatibleEncryptTableSubscriber.java
@@ -33,7 +33,8 @@ import org.apache.shardingsphere.infra.rule.RuleChangedSubscriber;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
-import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.Map;
import java.util.Optional;
@@ -63,15 +64,7 @@ public final class CompatibleEncryptTableSubscriber implements RuleChangedSubscr
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
EncryptTableRuleConfiguration needToAddedConfig = swapEncryptTableRuleConfig(
instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
- Optional<EncryptRule> rule = database.getRuleMetaData().findSingleRule(EncryptRule.class);
- CompatibleEncryptRuleConfiguration config;
- if (rule.isPresent()) {
- config = (CompatibleEncryptRuleConfiguration) rule.get().getConfiguration();
- config.getTables().add(needToAddedConfig);
- } else {
- config = new CompatibleEncryptRuleConfiguration(Collections.singletonList(needToAddedConfig), Collections.emptyMap());
- }
- instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), getCompatibleEncryptRuleConfiguration(database, needToAddedConfig)));
}
/**
@@ -112,4 +105,19 @@ public final class CompatibleEncryptTableSubscriber implements RuleChangedSubscr
private EncryptTableRuleConfiguration swapEncryptTableRuleConfig(final String yamlContext) {
return new YamlEncryptTableRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlEncryptTableRuleConfiguration.class));
}
+
+ private CompatibleEncryptRuleConfiguration getCompatibleEncryptRuleConfiguration(final ShardingSphereDatabase database, final EncryptTableRuleConfiguration needToAddedConfig) {
+ Optional<EncryptRule> rule = database.getRuleMetaData().findSingleRule(EncryptRule.class);
+ CompatibleEncryptRuleConfiguration config = rule.map(encryptRule -> getCompatibleEncryptRuleConfiguration((CompatibleEncryptRuleConfiguration) encryptRule.getConfiguration()))
+ .orElseGet(() -> new CompatibleEncryptRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>()));
+ config.getTables().add(needToAddedConfig);
+ return config;
+ }
+
+ private CompatibleEncryptRuleConfiguration getCompatibleEncryptRuleConfiguration(final CompatibleEncryptRuleConfiguration config) {
+ if (null == config.getTables()) {
+ return new CompatibleEncryptRuleConfiguration(new LinkedList<>(), config.getEncryptors());
+ }
+ return config;
+ }
}
diff --git a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/compatible/CompatibleEncryptorSubscriber.java b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/compatible/CompatibleEncryptorSubscriber.java
index 5bf08d9722d..4fac4e9da9c 100644
--- a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/compatible/CompatibleEncryptorSubscriber.java
+++ b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/subscriber/compatible/CompatibleEncryptorSubscriber.java
@@ -32,7 +32,10 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmC
import org.apache.shardingsphere.infra.yaml.config.swapper.algorithm.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.Map;
+import java.util.Optional;
/**
* Compatible encrypt encryptor subscriber.
@@ -58,9 +61,7 @@ public final class CompatibleEncryptorSubscriber implements RuleChangedSubscribe
return;
}
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- CompatibleEncryptRuleConfiguration config = (CompatibleEncryptRuleConfiguration) database.getRuleMetaData().getSingleRule(EncryptRule.class).getConfiguration();
- config.getEncryptors().put(event.getEncryptorName(), swapToAlgorithmConfig(
- instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), getCompatibleEncryptRuleConfiguration(database, event)));
}
/**
@@ -79,6 +80,22 @@ public final class CompatibleEncryptorSubscriber implements RuleChangedSubscribe
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
+ private CompatibleEncryptRuleConfiguration getCompatibleEncryptRuleConfiguration(final ShardingSphereDatabase database, final AlterCompatibleEncryptorEvent event) {
+ Optional<EncryptRule> rule = database.getRuleMetaData().findSingleRule(EncryptRule.class);
+ CompatibleEncryptRuleConfiguration config = rule.map(encryptRule -> getEncryptRuleConfiguration((CompatibleEncryptRuleConfiguration) encryptRule.getConfiguration()))
+ .orElseGet(() -> new CompatibleEncryptRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>()));
+ config.getEncryptors().put(event.getEncryptorName(), swapToAlgorithmConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
+ return config;
+ }
+
+ private CompatibleEncryptRuleConfiguration getEncryptRuleConfiguration(final CompatibleEncryptRuleConfiguration config) {
+ if (null == config.getEncryptors()) {
+ return new CompatibleEncryptRuleConfiguration(config.getTables(), new LinkedHashMap<>());
+ }
+ return config;
+ }
+
private AlgorithmConfiguration swapToAlgorithmConfig(final String yamlContext) {
return new YamlAlgorithmConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlAlgorithmConfiguration.class));
}
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 eb637312bad..503584230c1 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
@@ -69,6 +69,10 @@ public final class NewYamlCompatibleEncryptRuleConfigurationSwapper implements N
@Override
public CompatibleEncryptRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
+ if (dataNodes.stream().noneMatch(each -> encryptRuleNodePath.getRoot().isValidatedPath(each.getKey()))) {
+ // TODO refactor this use Optional
+ return null;
+ }
Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> encryptors = new HashMap<>();
for (YamlDataNode each : dataNodes) {
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 73719a2db3a..cf34ea1afb1 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
@@ -66,6 +66,9 @@ public final class NewYamlEncryptRuleConfigurationSwapper implements NewYamlRule
@Override
public EncryptRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
+ if (dataNodes.stream().noneMatch(each -> encryptRuleNodePath.getRoot().isValidatedPath(each.getKey()))) {
+ return null;
+ }
Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> encryptors = new HashMap<>();
for (YamlDataNode each : dataNodes) {
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapperTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapperTest.java
index 2b0917ebceb..7436dcfd550 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapperTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlCompatibleEncryptRuleConfigurationSwapperTest.java
@@ -33,6 +33,7 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@Deprecated
class NewYamlCompatibleEncryptRuleConfigurationSwapperTest {
@@ -66,8 +67,7 @@ class NewYamlCompatibleEncryptRuleConfigurationSwapperTest {
void assertSwapToObjectEmpty() {
Collection<YamlDataNode> config = new LinkedList<>();
CompatibleEncryptRuleConfiguration result = swapper.swapToObject(config);
- assertThat(result.getTables().size(), is(0));
- assertThat(result.getEncryptors().size(), is(0));
+ assertTrue(result == null);
}
@Test
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapperTest.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapperTest.java
index bf0753bede6..ab1302f1dc1 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapperTest.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/NewYamlEncryptRuleConfigurationSwapperTest.java
@@ -33,6 +33,7 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class NewYamlEncryptRuleConfigurationSwapperTest {
@@ -65,8 +66,7 @@ class NewYamlEncryptRuleConfigurationSwapperTest {
void assertSwapToObjectEmpty() {
Collection<YamlDataNode> config = new LinkedList<>();
EncryptRuleConfiguration result = swapper.swapToObject(config);
- assertThat(result.getTables().size(), is(0));
- assertThat(result.getEncryptors().size(), is(0));
+ assertTrue(result == null);
}
@Test
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskAlgorithmSubscriber.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskAlgorithmSubscriber.java
index 916081baaee..c203c9e16b5 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskAlgorithmSubscriber.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskAlgorithmSubscriber.java
@@ -27,14 +27,12 @@ import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.pojo.algorithm.YamlAlgorithmConfiguration;
import org.apache.shardingsphere.infra.yaml.config.swapper.algorithm.YamlAlgorithmConfigurationSwapper;
import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
-import org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
import org.apache.shardingsphere.mask.event.algorithm.AlterMaskAlgorithmEvent;
import org.apache.shardingsphere.mask.event.algorithm.DeleteMaskAlgorithmEvent;
import org.apache.shardingsphere.mask.rule.MaskRule;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
-import java.util.Collection;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Optional;
@@ -57,28 +55,11 @@ public final class MaskAlgorithmSubscriber implements RuleChangedSubscriber {
*/
@Subscribe
public synchronized void renew(final AlterMaskAlgorithmEvent event) {
- ShardingSphereDatabase database = databases.get(event.getDatabaseName());
- Optional<MaskRule> rule = database.getRuleMetaData().findSingleRule(MaskRule.class);
- MaskRuleConfiguration config;
- if (rule.isPresent()) {
- config = (MaskRuleConfiguration) rule.get().getConfiguration();
- if (null == config.getMaskAlgorithms()) {
- Map<String, AlgorithmConfiguration> maskAlgorithms = new HashMap<>();
- maskAlgorithms.put(event.getAlgorithmName(), swapToAlgorithmConfig(
- instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
- config = new MaskRuleConfiguration(config.getTables(), maskAlgorithms);
- } else {
- config.getMaskAlgorithms().put(event.getAlgorithmName(), swapToAlgorithmConfig(
- instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
- }
- } else {
- Collection<MaskTableRuleConfiguration> tables = new LinkedList<>();
- Map<String, AlgorithmConfiguration> maskAlgorithms = new HashMap<>();
- maskAlgorithms.put(event.getAlgorithmName(), swapToAlgorithmConfig(
- instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
- config = new MaskRuleConfiguration(tables, maskAlgorithms);
+ if (!event.getActiveVersion().equals(instanceContext.getModeContextManager().getActiveVersionByKey(event.getActiveVersionKey()))) {
+ return;
}
- instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ ShardingSphereDatabase database = databases.get(event.getDatabaseName());
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), getMaskRuleConfiguration(database, event)));
}
/**
@@ -94,6 +75,22 @@ public final class MaskAlgorithmSubscriber implements RuleChangedSubscriber {
instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
}
+ private MaskRuleConfiguration getMaskRuleConfiguration(final ShardingSphereDatabase database, final AlterMaskAlgorithmEvent event) {
+ Optional<MaskRule> rule = database.getRuleMetaData().findSingleRule(MaskRule.class);
+ MaskRuleConfiguration config = rule.map(encryptRule -> getMaskRuleConfiguration((MaskRuleConfiguration) encryptRule.getConfiguration()))
+ .orElseGet(() -> new MaskRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>()));
+ config.getMaskAlgorithms().put(event.getAlgorithmName(), swapToAlgorithmConfig(
+ instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion())));
+ return config;
+ }
+
+ private MaskRuleConfiguration getMaskRuleConfiguration(final MaskRuleConfiguration config) {
+ if (null == config.getMaskAlgorithms()) {
+ return new MaskRuleConfiguration(config.getTables(), new LinkedHashMap<>());
+ }
+ return config;
+ }
+
private AlgorithmConfiguration swapToAlgorithmConfig(final String yamlContext) {
return new YamlAlgorithmConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlAlgorithmConfiguration.class));
}
diff --git a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskTableSubscriber.java b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskTableSubscriber.java
index deed79f2d19..f113852e505 100644
--- a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskTableSubscriber.java
+++ b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/subscriber/MaskTableSubscriber.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.mask.subscriber;
import com.google.common.eventbus.Subscribe;
import lombok.Setter;
-import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.rule.RuleChangedSubscriber;
@@ -34,8 +33,7 @@ import org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfigur
import org.apache.shardingsphere.mask.yaml.swapper.rule.YamlMaskTableRuleConfigurationSwapper;
import org.apache.shardingsphere.mode.event.config.DatabaseRuleConfigurationChangedEvent;
-import java.util.Collection;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Optional;
@@ -64,24 +62,7 @@ public final class MaskTableSubscriber implements RuleChangedSubscriber {
ShardingSphereDatabase database = databases.get(event.getDatabaseName());
MaskTableRuleConfiguration needToAddedConfig = swapMaskTableRuleConfig(
instanceContext.getModeContextManager().getVersionPathByActiveVersionKey(event.getActiveVersionKey(), event.getActiveVersion()));
- Optional<MaskRule> rule = database.getRuleMetaData().findSingleRule(MaskRule.class);
- MaskRuleConfiguration config;
- if (rule.isPresent()) {
- config = (MaskRuleConfiguration) rule.get().getConfiguration();
- if (null == config.getTables()) {
- Collection<MaskTableRuleConfiguration> tables = new LinkedList<>();
- tables.add(needToAddedConfig);
- config = new MaskRuleConfiguration(tables, config.getMaskAlgorithms());
- } else {
- config.getTables().add(needToAddedConfig);
- }
- } else {
- Collection<MaskTableRuleConfiguration> tables = new LinkedList<>();
- tables.add(needToAddedConfig);
- Map<String, AlgorithmConfiguration> maskAlgorithms = new HashMap<>();
- config = new MaskRuleConfiguration(tables, maskAlgorithms);
- }
- instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), config));
+ instanceContext.getEventBusContext().post(new DatabaseRuleConfigurationChangedEvent(event.getDatabaseName(), getMaskRuleConfiguration(database, needToAddedConfig)));
}
/**
@@ -119,4 +100,19 @@ public final class MaskTableSubscriber implements RuleChangedSubscriber {
private MaskTableRuleConfiguration swapMaskTableRuleConfig(final String yamlContext) {
return new YamlMaskTableRuleConfigurationSwapper().swapToObject(YamlEngine.unmarshal(yamlContext, YamlMaskTableRuleConfiguration.class));
}
+
+ private MaskRuleConfiguration getMaskRuleConfiguration(final ShardingSphereDatabase database, final MaskTableRuleConfiguration needToAddedConfig) {
+ Optional<MaskRule> rule = database.getRuleMetaData().findSingleRule(MaskRule.class);
+ MaskRuleConfiguration config = rule.map(encryptRule -> getMaskRuleConfiguration((MaskRuleConfiguration) encryptRule.getConfiguration()))
+ .orElseGet(() -> new MaskRuleConfiguration(new LinkedList<>(), new LinkedHashMap<>()));
+ config.getTables().add(needToAddedConfig);
+ return config;
+ }
+
+ private MaskRuleConfiguration getMaskRuleConfiguration(final MaskRuleConfiguration config) {
+ if (null == config.getTables()) {
+ return new MaskRuleConfiguration(new LinkedList<>(), config.getMaskAlgorithms());
+ }
+ return config;
+ }
}
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 04bda6f9579..620abb42ddc 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
@@ -64,6 +64,10 @@ public final class NewYamlMaskRuleConfigurationSwapper implements NewYamlRuleCon
@Override
public MaskRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
+ if (dataNodes.stream().noneMatch(each -> maskRuleNodePath.getRoot().isValidatedPath(each.getKey()))) {
+ // TODO refactor this use Optional
+ return null;
+ }
Collection<MaskTableRuleConfiguration> tables = new LinkedList<>();
Map<String, AlgorithmConfiguration> algorithms = new LinkedHashMap<>();
for (YamlDataNode each : dataNodes) {
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapperTest.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapperTest.java
index ac754f7de83..b83388921f6 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapperTest.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/NewYamlMaskRuleConfigurationSwapperTest.java
@@ -32,6 +32,7 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class NewYamlMaskRuleConfigurationSwapperTest {
@@ -64,8 +65,7 @@ class NewYamlMaskRuleConfigurationSwapperTest {
void assertSwapToObjectEmpty() {
Collection<YamlDataNode> config = new LinkedList<>();
MaskRuleConfiguration result = swapper.swapToObject(config);
- assertThat(result.getTables().size(), is(0));
- assertThat(result.getMaskAlgorithms().size(), is(0));
+ assertTrue(result == null);
}
@Test
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 b8958cc2be4..19230aae00e 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
@@ -73,6 +73,10 @@ public final class NewYamlReadwriteSplittingRuleConfigurationSwapper implements
@Override
public ReadwriteSplittingRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
+ if (dataNodes.stream().noneMatch(each -> readwriteSplittingRuleNodePath.getRoot().isValidatedPath(each.getKey()))) {
+ // TODO refactor this use Optional
+ return null;
+ }
Collection<ReadwriteSplittingDataSourceRuleConfiguration> dataSources = new LinkedList<>();
Map<String, AlgorithmConfiguration> loadBalancerMap = new LinkedHashMap<>();
for (YamlDataNode each : dataNodes) {
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapperTest.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapperTest.java
index 21c5b690d1f..cd9a63b96ee 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapperTest.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/NewYamlReadwriteSplittingRuleConfigurationSwapperTest.java
@@ -33,6 +33,7 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class NewYamlReadwriteSplittingRuleConfigurationSwapperTest {
@@ -62,8 +63,7 @@ class NewYamlReadwriteSplittingRuleConfigurationSwapperTest {
void assertSwapToObjectEmpty() {
Collection<YamlDataNode> config = new LinkedList<>();
ReadwriteSplittingRuleConfiguration result = swapper.swapToObject(config);
- assertThat(result.getDataSources().size(), is(0));
- assertThat(result.getLoadBalancers().size(), is(0));
+ assertTrue(result == null);
}
@Test
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 8c3851b6d74..8e2cc390c3d 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
@@ -80,6 +80,10 @@ public final class NewYamlShadowRuleConfigurationSwapper implements NewYamlRuleC
@Override
public ShadowRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
+ if (dataNodes.stream().noneMatch(each -> shadowRuleNodePath.getRoot().isValidatedPath(each.getKey()))) {
+ // TODO refactor this use Optional
+ return null;
+ }
ShadowRuleConfiguration result = new ShadowRuleConfiguration();
for (YamlDataNode each : dataNodes) {
shadowRuleNodePath.getNamedItem(ShadowNodePath.DATA_SOURCES).getName(each.getKey())
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapperTest.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapperTest.java
index 2ce4f375886..bf51b316536 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapperTest.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/NewYamlShadowRuleConfigurationSwapperTest.java
@@ -34,6 +34,7 @@ import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
class NewYamlShadowRuleConfigurationSwapperTest {
@@ -77,8 +78,7 @@ class NewYamlShadowRuleConfigurationSwapperTest {
void assertSwapToObjectEmpty() {
Collection<YamlDataNode> config = new LinkedList<>();
ShadowRuleConfiguration result = swapper.swapToObject(config);
- assertThat(result.getTables().size(), is(0));
- assertThat(result.getShadowAlgorithms().size(), is(0));
+ assertTrue(result == null);
}
@Test
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 d58671b2634..62cc823195a 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
@@ -137,6 +137,10 @@ public final class NewYamlShardingRuleConfigurationSwapper implements NewYamlRul
@Override
public ShardingRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
+ if (dataNodes.stream().noneMatch(each -> shardingRuleNodePath.getRoot().isValidatedPath(each.getKey()))) {
+ // TODO refactor this use Optional
+ return null;
+ }
ShardingRuleConfiguration result = new ShardingRuleConfiguration();
for (YamlDataNode each : dataNodes) {
shardingRuleNodePath.getNamedItem(ShardingNodePath.TABLES).getName(each.getKey())
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapperTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapperTest.java
index 0267a078ed4..88f1016bf2f 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapperTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/NewYamlShardingRuleConfigurationSwapperTest.java
@@ -115,18 +115,7 @@ class NewYamlShardingRuleConfigurationSwapperTest {
void assertSwapToObjectEmpty() {
Collection<YamlDataNode> config = new LinkedList<>();
ShardingRuleConfiguration result = swapper.swapToObject(config);
- assertThat(result.getTables().size(), is(0));
- assertThat(result.getAutoTables().size(), is(0));
- assertThat(result.getBindingTableGroups().size(), is(0));
- assertNull(result.getDefaultDatabaseShardingStrategy());
- assertNull(result.getDefaultTableShardingStrategy());
- assertNull(result.getDefaultKeyGenerateStrategy());
- assertNull(result.getDefaultAuditStrategy());
- assertNull(result.getDefaultShardingColumn());
- assertThat(result.getShardingAlgorithms().size(), is(0));
- assertThat(result.getKeyGenerators().size(), is(0));
- assertThat(result.getAuditors().size(), is(0));
- assertNull(result.getShardingCache());
+ assertTrue(result == null);
}
@Test
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/rule/NewYamlRuleConfigurationSwapperEngine.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/rule/NewYamlRuleConfigurationSwapperEngine.java
index 43c41b856ea..d7429570d32 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/rule/NewYamlRuleConfigurationSwapperEngine.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/rule/NewYamlRuleConfigurationSwapperEngine.java
@@ -24,6 +24,7 @@ import org.apache.shardingsphere.infra.util.yaml.datanode.YamlDataNode;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;
+import java.util.Objects;
/**
* TODO Rename YamlRuleConfigurationSwapper when metadata structure adjustment completed. #25485
@@ -54,6 +55,7 @@ public final class NewYamlRuleConfigurationSwapperEngine {
for (NewYamlRuleConfigurationSwapper each : OrderedSPILoader.getServices(NewYamlRuleConfigurationSwapper.class)) {
result.add((RuleConfiguration) each.swapToObject(dataNodes));
}
+ result.removeIf(Objects::isNull);
return result;
}
}
diff --git a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
index 36efbaf5148..611197ba0af 100644
--- a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
+++ b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/NewYamlSingleRuleConfigurationSwapper.java
@@ -51,6 +51,10 @@ public final class NewYamlSingleRuleConfigurationSwapper implements NewYamlRuleC
@Override
public SingleRuleConfiguration swapToObject(final Collection<YamlDataNode> dataNodes) {
+ if (dataNodes.stream().noneMatch(each -> singleRuleNodePath.getRoot().isValidatedPath(each.getKey()))) {
+ // TODO refactor this use Optional
+ return null;
+ }
for (YamlDataNode each : dataNodes) {
if (singleRuleNodePath.getUniqueItem(SingleNodePath.TABLES).isValidatedPath(each.getKey())) {
return swapToObject(YamlEngine.unmarshal(each.getValue(), YamlSingleRuleConfiguration.class));
diff --git a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/FilePluginE2EIT.java b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/FilePluginE2EIT.java
index 8fe1395f381..40e6e2d283e 100644
--- a/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/FilePluginE2EIT.java
+++ b/test/e2e/agent/plugins/logging/file/src/test/java/org/apache/shardingsphere/test/e2e/agent/file/FilePluginE2EIT.java
@@ -37,7 +37,7 @@ class FilePluginE2EIT {
void assertWithAgent() {
assertTrue(new File(LogLoader.getLogFilePath(E2ETestEnvironment.getInstance().isAdaptedProxy())).exists(),
String.format("The file `%s` does not exist", LogLoader.getLogFilePath(E2ETestEnvironment.getInstance().isAdaptedProxy())));
- Collection<String> actualLogLines = LogLoader.getLogLines(LogLoader.getLogFilePath(E2ETestEnvironment.getInstance().isAdaptedProxy()),
+ Collection<String> actualLogLines = LogLoader.getLogLines(LogLoader.getLogFilePath(E2ETestEnvironment.getInstance().isAdaptedProxy()),
E2ETestEnvironment.getInstance().isAdaptedProxy());
assertFalse(actualLogLines.isEmpty(), "Actual log is empty");
if (E2ETestEnvironment.getInstance().isAdaptedProxy()) {