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

chengzhang 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 b6e035d1238 Minor refactor for EncryptRule build RuleAttributes 
(#33184)
b6e035d1238 is described below

commit b6e035d1238550fe111b7cd0d701b6b086764397
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Wed Oct 9 16:57:52 2024 +0800

    Minor refactor for EncryptRule build RuleAttributes (#33184)
---
 .../org/apache/shardingsphere/encrypt/rule/EncryptRule.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
index fa9c08181c2..a60a399481e 100644
--- 
a/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
+++ 
b/features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
@@ -68,7 +68,11 @@ public final class EncryptRule implements DatabaseRule, 
PartialRuleUpdateSupport
             each.getColumns().forEach(this::checkEncryptorType);
             tables.put(each.getName(), new EncryptTable(each, encryptors));
         }
-        attributes.set(new RuleAttributes(new 
EncryptTableMapperRuleAttribute(tables.keySet())));
+        attributes.set(buildRuleAttributes());
+    }
+    
+    private RuleAttributes buildRuleAttributes() {
+        return new RuleAttributes(new 
EncryptTableMapperRuleAttribute(tables.keySet()));
     }
     
     private Map<String, EncryptAlgorithm> createEncryptors(final 
EncryptRuleConfiguration ruleConfig) {
@@ -156,13 +160,13 @@ public final class EncryptRule implements DatabaseRule, 
PartialRuleUpdateSupport
         Collection<String> toBeAddedTableNames = 
toBeUpdatedTablesNames.stream().filter(each -> 
!tables.containsKey(each)).collect(Collectors.toList());
         if (!toBeAddedTableNames.isEmpty()) {
             toBeAddedTableNames.forEach(each -> addTableRule(each, 
toBeUpdatedRuleConfig));
-            attributes.set(new RuleAttributes(new 
EncryptTableMapperRuleAttribute(tables.keySet())));
+            attributes.set(buildRuleAttributes());
             return true;
         }
         Collection<String> toBeRemovedTableNames = 
tables.keySet().stream().filter(each -> 
!toBeUpdatedTablesNames.contains(each)).collect(Collectors.toList());
         if (!toBeRemovedTableNames.isEmpty()) {
             toBeRemovedTableNames.forEach(tables::remove);
-            attributes.set(new RuleAttributes(new 
EncryptTableMapperRuleAttribute(tables.keySet())));
+            attributes.set(buildRuleAttributes());
             // TODO check and remove unused INLINE encryptors
             return true;
         }

Reply via email to