You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2026/04/09 17:43:20 UTC

(shardingsphere) branch master updated: Revert #38539 (Refactor YamlRuleNodeTupleSwapperEngine) (#38607)

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

jianglongtao 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 39382ef5123 Revert #38539 (Refactor YamlRuleNodeTupleSwapperEngine) (#38607)
39382ef5123 is described below

commit 39382ef5123bd7641c962588ecc5cb9a862d19ab
Author: Raigor <ra...@gmail.com>
AuthorDate: Fri Apr 10 01:43:13 2026 +0800

    Revert #38539 (Refactor YamlRuleNodeTupleSwapperEngine) (#38607)
---
 .../mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngine.java           | 2 +-
 .../mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java       | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngine.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngine.java
index c9c33fe22fe..fd2cd0da2cb 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngine.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngine.java
@@ -119,7 +119,7 @@ public final class YamlRuleNodeTupleSwapperEngine {
     private Optional<RuleNodeTuple> swapToUniqueTuple(final String databaseName, final String ruleType, final String ruleItemType, final Object fieldValue) {
         DatabaseRuleNodePath databaseRuleNodePath = new DatabaseRuleNodePath(databaseName, ruleType, new DatabaseRuleItem(ruleItemType));
         if (fieldValue instanceof Collection) {
-            return Optional.of(new RuleNodeTuple(databaseRuleNodePath, YamlEngine.marshal(fieldValue)));
+            return ((Collection) fieldValue).isEmpty() ? Optional.empty() : Optional.of(new RuleNodeTuple(databaseRuleNodePath, YamlEngine.marshal(fieldValue)));
         }
         if (fieldValue instanceof String) {
             return ((String) fieldValue).isEmpty() ? Optional.empty() : Optional.of(new RuleNodeTuple(databaseRuleNodePath, fieldValue.toString()));
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java
index 07f88982b89..ee8795a1090 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java
@@ -33,7 +33,6 @@ import java.util.List;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 class YamlRuleNodeTupleSwapperEngineTest {
@@ -47,7 +46,7 @@ class YamlRuleNodeTupleSwapperEngineTest {
     
     @Test
     void assertSwapToTuplesWithEmptyNodeYamlRuleConfiguration() {
-        assertFalse(new YamlRuleNodeTupleSwapperEngine().swapToTuples("foo_db", new YamlNodeRuleConfiguration()).isEmpty());
+        assertTrue(new YamlRuleNodeTupleSwapperEngine().swapToTuples("foo_db", new YamlNodeRuleConfiguration()).isEmpty());
     }
     
     @Test