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

panjuan 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 ec6cb96e914 Avoid catch Exception in Proxy codes (#26533)
ec6cb96e914 is described below

commit ec6cb96e914fa927e1dbd68d18244f099c4735f2
Author: 吴伟杰 <[email protected]>
AuthorDate: Sun Jul 2 15:39:16 2023 +0800

    Avoid catch Exception in Proxy codes (#26533)
---
 .../db/protocol/mysql/codec/MySQLPacketCodecEngine.java               | 2 +-
 .../db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java       | 2 +-
 .../db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java     | 2 +-
 .../backend/mysql/handler/admin/executor/MySQLSetCharsetExecutor.java | 4 +---
 4 files changed, 4 insertions(+), 6 deletions(-)

diff --git 
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java
 
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java
index b27ea44a13e..cd80731ab5a 100644
--- 
a/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java
+++ 
b/db-protocol/mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/codec/MySQLPacketCodecEngine.java
@@ -92,7 +92,7 @@ public final class MySQLPacketCodecEngine implements 
DatabasePacketCodecEngine {
         try {
             message.write(payload);
             // CHECKSTYLE:OFF
-        } catch (final Exception ex) {
+        } catch (final RuntimeException ex) {
             // CHECKSTYLE:ON
             out.resetWriterIndex();
             SQLException unknownSQLException = new 
UnknownSQLException(ex).toSQLException();
diff --git 
a/db-protocol/opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java
 
b/db-protocol/opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java
index c304175c1f9..87a71a21976 100644
--- 
a/db-protocol/opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java
+++ 
b/db-protocol/opengauss/src/main/java/org/apache/shardingsphere/db/protocol/opengauss/codec/OpenGaussPacketCodecEngine.java
@@ -115,7 +115,7 @@ public final class OpenGaussPacketCodecEngine implements 
DatabasePacketCodecEngi
         try {
             message.write(payload);
             // CHECKSTYLE:OFF
-        } catch (final Exception ex) {
+        } catch (final RuntimeException ex) {
             // CHECKSTYLE:ON
             payload.getByteBuf().resetWriterIndex();
             // TODO consider what severity to use
diff --git 
a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java
 
b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java
index 3b5262c1bab..eec735726a7 100644
--- 
a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java
+++ 
b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/codec/PostgreSQLPacketCodecEngine.java
@@ -113,7 +113,7 @@ public final class PostgreSQLPacketCodecEngine implements 
DatabasePacketCodecEng
         try {
             message.write(payload);
             // CHECKSTYLE:OFF
-        } catch (final Exception ex) {
+        } catch (final RuntimeException ex) {
             // CHECKSTYLE:ON
             payload.getByteBuf().resetWriterIndex();
             // TODO consider what severity to use
diff --git 
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetCharsetExecutor.java
 
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetCharsetExecutor.java
index 9583ddec930..392215d6abd 100644
--- 
a/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetCharsetExecutor.java
+++ 
b/proxy/backend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetCharsetExecutor.java
@@ -61,9 +61,7 @@ public final class MySQLSetCharsetExecutor implements 
MySQLSessionVariableHandle
             default:
                 try {
                     return Charset.forName(value);
-                    // CHECKSTYLE:OFF
-                } catch (final Exception ex) {
-                    // CHECKSTYLE:ON
+                } catch (final IllegalArgumentException ex) {
                     throw new UnknownCharsetException(value.toLowerCase());
                 }
         }

Reply via email to