You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ki...@apache.org on 2020/09/11 17:03:55 UTC

[shardingsphere] branch master updated: Log error message for unexpected exception only (#7414)

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

kimmking 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 046e9ab   Log error message for unexpected exception only (#7414)
046e9ab is described below

commit 046e9ab8a15dfd7c2b3214e98073da5cd798fe00
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Sep 12 01:03:35 2020 +0800

     Log error message for unexpected exception only (#7414)
    
    * Log error message if not runtime exception only
    
    * Add todo
---
 .../proxy/frontend/command/CommandExecutorTask.java              | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
index 82d4f00..10724d5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/command/CommandExecutorTask.java
@@ -74,10 +74,12 @@ public final class CommandExecutorTask implements Runnable {
             // CHECKSTYLE:OFF
         } catch (final Exception ex) {
             // CHECKSTYLE:ON
-            log.error("Exception occur: ", ex);
             context.writeAndFlush(databaseProtocolFrontendEngine.getCommandExecuteEngine().getErrorPacket(ex));
             Optional<DatabasePacket<?>> databasePacket = databaseProtocolFrontendEngine.getCommandExecuteEngine().getOtherPacket();
             databasePacket.ifPresent(context::writeAndFlush);
+            if (!isExpectedException(ex)) {
+                log.error("Exception occur: ", ex);
+            }
         } finally {
             if (isNeedFlush) {
                 context.flush();
@@ -86,6 +88,11 @@ public final class CommandExecutorTask implements Runnable {
         }
     }
     
+    // TODO finish expected exception
+    private boolean isExpectedException(final Exception ex) {
+        return ex instanceof RuntimeException;
+    }
+    
     private boolean executeCommand(final ChannelHandlerContext context, final PacketPayload payload, final BackendConnection backendConnection) throws SQLException {
         CommandExecuteEngine commandExecuteEngine = databaseProtocolFrontendEngine.getCommandExecuteEngine();
         CommandPacketType type = commandExecuteEngine.getCommandPacketType(payload);