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

zhangliang 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 5afcc92c7ed Extract assignment out of expr in 
MySQLSystemVariableQueryExecutor (#25835)
5afcc92c7ed is described below

commit 5afcc92c7ed951e27a8e0be50038f6e5e2143cd5
Author: 吴伟杰 <[email protected]>
AuthorDate: Mon May 22 11:33:02 2023 +0800

    Extract assignment out of expr in MySQLSystemVariableQueryExecutor (#25835)
    
    * Extract assignment out of expr in MySQLSystemVariableQueryExecutor
    
    
https://sonarcloud.io/project/issues?resolved=false&rules=java%3AS1121&id=apache_shardingsphere&open=AYfA1-AZtGAAaUtvu0f-
    
    * Correct test class naming
---
 .../handler/admin/executor/MySQLSystemVariableQueryExecutor.java   | 7 +++++--
 ...ExecutorTest.java => MySQLSystemVariableQueryExecutorTest.java} | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutor.java
 
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutor.java
index 3bfc63b6db6..4009b3fd4b5 100644
--- 
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutor.java
+++ 
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutor.java
@@ -86,8 +86,11 @@ public final class MySQLSystemVariableQueryExecutor 
implements DatabaseAdminQuer
         List<ExpressionProjectionSegment> expressionProjectionSegments = new 
ArrayList<>(projections.size());
         List<MySQLSystemVariable> variables = new 
ArrayList<>(projections.size());
         for (ProjectionSegment each : projections) {
-            ExpressionProjectionSegment expression;
-            if (!(each instanceof ExpressionProjectionSegment) || 
!((expression = (ExpressionProjectionSegment) each).getExpr() instanceof 
VariableSegment)) {
+            if (!(each instanceof ExpressionProjectionSegment)) {
+                return Optional.empty();
+            }
+            ExpressionProjectionSegment expression = 
(ExpressionProjectionSegment) each;
+            if (!(expression.getExpr() instanceof VariableSegment)) {
                 return Optional.empty();
             }
             expressionProjectionSegments.add(expression);
diff --git 
a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLMySQLSystemVariableQueryExecutorTest.java
 
b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutorTest.java
similarity index 99%
rename from 
proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLMySQLSystemVariableQueryExecutorTest.java
rename to 
proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutorTest.java
index 2f20736d564..a2613f70e09 100644
--- 
a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLMySQLSystemVariableQueryExecutorTest.java
+++ 
b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSystemVariableQueryExecutorTest.java
@@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-class MySQLMySQLSystemVariableQueryExecutorTest {
+class MySQLSystemVariableQueryExecutorTest {
     
     @Test
     void 
assertTryGetSystemVariableQueryExecutorWithOtherExpressionProjection() {

Reply via email to