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

duanzhengqiang 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 d5b2f4e1eaf Use accurate positions for SuppressWarnings (#23991)
d5b2f4e1eaf is described below

commit d5b2f4e1eaf9b5416774f18af3ac671e7907fd69
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Feb 4 13:14:21 2023 +0800

    Use accurate positions for SuppressWarnings (#23991)
    
    * Adjust sequence of JobRateLimitAlgorithm
    
    * Remove FixtureDataSourcePreparer
    
    * Refactor ClusterModeContextManager
    
    * Refactor ClusterModeContextManager
    
    * Refactor ClusterContextManagerBuilder
    
    * Use accurate positions for SuppressWarnings
    
    * Use accurate positions for SuppressWarnings
    
    * Remove useless getter
    
    * Remove useless getter
---
 .../shardingsphere/encrypt/rule/EncryptRule.java   | 41 ++++++++++++++--------
 .../EncryptParameterRewriterBuilderTest.java       |  4 +--
 2 files changed, 27 insertions(+), 18 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 6c693a83595..4dcb140c13e 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
@@ -46,19 +46,19 @@ import java.util.Optional;
 /**
  * Encrypt rule.
  */
-@SuppressWarnings({"unchecked", "rawtypes"})
 public final class EncryptRule implements DatabaseRule, TableContainedRule {
     
     @Getter
     private final RuleConfiguration configuration;
     
+    @SuppressWarnings("rawtypes")
     private final Map<String, StandardEncryptAlgorithm> standardEncryptors = 
new LinkedHashMap<>();
     
+    @SuppressWarnings("rawtypes")
     private final Map<String, LikeEncryptAlgorithm> likeEncryptors = new 
LinkedHashMap<>();
     
     private final Map<String, EncryptTable> tables = new LinkedHashMap<>();
     
-    @Getter
     private final boolean queryWithCipherColumn;
     
     public EncryptRule(final EncryptRuleConfiguration ruleConfig) {
@@ -68,6 +68,7 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
         queryWithCipherColumn = ruleConfig.isQueryWithCipherColumn();
     }
     
+    @SuppressWarnings("rawtypes")
     private void putAllEncryptors(final String encryptorName, final 
EncryptAlgorithm algorithm) {
         if (algorithm instanceof StandardEncryptAlgorithm) {
             standardEncryptors.put(encryptorName, (StandardEncryptAlgorithm) 
algorithm);
@@ -104,6 +105,7 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
      * @param logicColumn logic column name
      * @return encryptor
      */
+    @SuppressWarnings("rawtypes")
     public Optional<StandardEncryptAlgorithm> findEncryptor(final String 
logicTable, final String logicColumn) {
         String lowerCaseLogicTable = logicTable.toLowerCase();
         return tables.containsKey(lowerCaseLogicTable) ? 
tables.get(lowerCaseLogicTable).findEncryptorName(logicColumn).map(standardEncryptors::get)
 : Optional.empty();
@@ -116,6 +118,7 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
      * @param logicColumn logic column name
      * @return encryptor
      */
+    @SuppressWarnings("rawtypes")
     public Optional<StandardEncryptAlgorithm> findAssistedQueryEncryptor(final 
String logicTable, final String logicColumn) {
         String lowerCaseLogicTable = logicTable.toLowerCase();
         return tables.containsKey(lowerCaseLogicTable) ? 
tables.get(lowerCaseLogicTable).findAssistedQueryEncryptorName(logicColumn).map(standardEncryptors::get)
 : Optional.empty();
@@ -128,6 +131,7 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
      * @param logicColumn logic column name
      * @return like query encryptor
      */
+    @SuppressWarnings("rawtypes")
     public Optional<LikeEncryptAlgorithm> findLikeQueryEncryptor(final String 
logicTable, final String logicColumn) {
         String lowerCaseLogicTable = logicTable.toLowerCase();
         return tables.containsKey(lowerCaseLogicTable) ? 
tables.get(lowerCaseLogicTable).findLikeQueryEncryptorName(logicColumn).map(likeEncryptors::get)
 : Optional.empty();
@@ -144,6 +148,7 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
      * @return encrypt values
      */
     public List<Object> getEncryptValues(final String databaseName, final 
String schemaName, final String logicTable, final String logicColumn, final 
List<Object> originalValues) {
+        @SuppressWarnings("rawtypes")
         Optional<StandardEncryptAlgorithm> encryptor = 
findEncryptor(logicTable, logicColumn);
         EncryptContext encryptContext = 
EncryptContextBuilder.build(databaseName, schemaName, logicTable, logicColumn);
         ShardingSpherePreconditions.checkState(encryptor.isPresent(),
@@ -151,7 +156,8 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
         return getEncryptValues(encryptor.get(), originalValues, 
encryptContext);
     }
     
-    private List<Object> getEncryptValues(final StandardEncryptAlgorithm 
encryptor, final List<Object> originalValues, final EncryptContext 
encryptContext) {
+    @SuppressWarnings("unchecked")
+    private List<Object> getEncryptValues(@SuppressWarnings("rawtypes") final 
StandardEncryptAlgorithm encryptor, final List<Object> originalValues, final 
EncryptContext encryptContext) {
         List<Object> result = new LinkedList<>();
         for (Object each : originalValues) {
             Object encryptValue = null == each ? null : 
encryptor.encrypt(each, encryptContext);
@@ -237,6 +243,7 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
      * @return assisted query values
      */
     public List<Object> getEncryptAssistedQueryValues(final String 
databaseName, final String schemaName, final String logicTable, final String 
logicColumn, final List<Object> originalValues) {
+        @SuppressWarnings("rawtypes")
         Optional<StandardEncryptAlgorithm> encryptor = 
findAssistedQueryEncryptor(logicTable, logicColumn);
         EncryptContext encryptContext = 
EncryptContextBuilder.build(databaseName, schemaName, logicTable, logicColumn);
         ShardingSpherePreconditions.checkState(encryptor.isPresent(),
@@ -244,7 +251,9 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
         return getEncryptAssistedQueryValues(encryptor.get(), originalValues, 
encryptContext);
     }
     
-    private List<Object> getEncryptAssistedQueryValues(final 
StandardEncryptAlgorithm encryptor, final List<Object> originalValues, final 
EncryptContext encryptContext) {
+    @SuppressWarnings("unchecked")
+    private List<Object> 
getEncryptAssistedQueryValues(@SuppressWarnings("rawtypes") final 
StandardEncryptAlgorithm encryptor,
+                                                       final List<Object> 
originalValues, final EncryptContext encryptContext) {
         List<Object> result = new LinkedList<>();
         for (Object each : originalValues) {
             result.add(null == each ? null : encryptor.encrypt(each, 
encryptContext));
@@ -263,6 +272,7 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
      * @return like query values
      */
     public List<Object> getEncryptLikeQueryValues(final String databaseName, 
final String schemaName, final String logicTable, final String logicColumn, 
final List<Object> originalValues) {
+        @SuppressWarnings("rawtypes")
         Optional<LikeEncryptAlgorithm> encryptor = 
findLikeQueryEncryptor(logicTable, logicColumn);
         EncryptContext encryptContext = 
EncryptContextBuilder.build(databaseName, schemaName, logicTable, logicColumn);
         ShardingSpherePreconditions.checkState(encryptor.isPresent(),
@@ -270,7 +280,8 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
         return getEncryptLikeQueryValues(encryptor.get(), originalValues, 
encryptContext);
     }
     
-    private List<Object> getEncryptLikeQueryValues(final LikeEncryptAlgorithm 
encryptor, final List<Object> originalValues, final EncryptContext 
encryptContext) {
+    @SuppressWarnings("unchecked")
+    private List<Object> 
getEncryptLikeQueryValues(@SuppressWarnings("rawtypes") final 
LikeEncryptAlgorithm encryptor, final List<Object> originalValues, final 
EncryptContext encryptContext) {
         List<Object> result = new LinkedList<>();
         for (Object each : originalValues) {
             result.add(null == each ? null : encryptor.encrypt(each, 
encryptContext));
@@ -310,16 +321,6 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
         return Optional.empty();
     }
     
-    @Override
-    public Collection<String> getTables() {
-        return tables.keySet();
-    }
-    
-    @Override
-    public String getType() {
-        return EncryptRule.class.getSimpleName();
-    }
-    
     /**
      * Set schema meta data.
      *
@@ -334,4 +335,14 @@ public final class EncryptRule implements DatabaseRule, 
TableContainedRule {
             }
         }
     }
+    
+    @Override
+    public Collection<String> getTables() {
+        return tables.keySet();
+    }
+    
+    @Override
+    public String getType() {
+        return EncryptRule.class.getSimpleName();
+    }
 }
diff --git 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilderTest.java
 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilderTest.java
index fb72a998004..5690fad8139 100644
--- 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilderTest.java
+++ 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameter/EncryptParameterRewriterBuilderTest.java
@@ -39,14 +39,13 @@ import static org.mockito.Mockito.when;
 
 public final class EncryptParameterRewriterBuilderTest {
     
-    @SuppressWarnings("rawtypes")
     @Test
     public void assertGetParameterRewritersWhenPredicateIsNeedRewrite() {
         EncryptRule encryptRule = mock(EncryptRule.class, RETURNS_DEEP_STUBS);
-        when(encryptRule.isQueryWithCipherColumn()).thenReturn(true);
         
when(encryptRule.findEncryptTable("t_order").isPresent()).thenReturn(true);
         SQLStatementContext<?> sqlStatementContext = 
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
         
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_order"));
+        @SuppressWarnings("rawtypes")
         Collection<ParameterRewriter> actual = new 
EncryptParameterRewriterBuilder(
                 encryptRule, DefaultDatabase.LOGIC_NAME, 
Collections.singletonMap("test", mock(ShardingSphereSchema.class)), 
sqlStatementContext, Collections.emptyList()).getParameterRewriters();
         assertThat(actual.size(), is(1));
@@ -56,7 +55,6 @@ public final class EncryptParameterRewriterBuilderTest {
     @Test
     public void assertGetParameterRewritersWhenPredicateIsNotNeedRewrite() {
         EncryptRule encryptRule = mock(EncryptRule.class, RETURNS_DEEP_STUBS);
-        when(encryptRule.isQueryWithCipherColumn()).thenReturn(true);
         SelectStatementContext sqlStatementContext = 
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
         
when(sqlStatementContext.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_order"));
         
when(sqlStatementContext.getWhereSegments()).thenReturn(Collections.emptyList());

Reply via email to