You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/05/11 13:55:51 UTC

[iotdb] branch xingtanzjr/0511_test updated: catch throwable

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

xingtanzjr pushed a commit to branch xingtanzjr/0511_test
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/xingtanzjr/0511_test by this push:
     new 452084a4f8 catch throwable
452084a4f8 is described below

commit 452084a4f8cb2c7f1ab1eefff51da8e33f94d377
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Wed May 11 21:55:42 2022 +0800

    catch throwable
---
 .../sync/SyncThriftClientWithErrorHandler.java     | 52 +++++++++++-----------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/node-commons/src/main/java/org/apache/iotdb/commons/client/sync/SyncThriftClientWithErrorHandler.java b/node-commons/src/main/java/org/apache/iotdb/commons/client/sync/SyncThriftClientWithErrorHandler.java
index f710300c85..651b5a8466 100644
--- a/node-commons/src/main/java/org/apache/iotdb/commons/client/sync/SyncThriftClientWithErrorHandler.java
+++ b/node-commons/src/main/java/org/apache/iotdb/commons/client/sync/SyncThriftClientWithErrorHandler.java
@@ -52,9 +52,13 @@ public class SyncThriftClientWithErrorHandler implements MethodInterceptor {
       throws Throwable {
     try {
       return methodProxy.invokeSuper(o, objects);
-    } catch (InvocationTargetException e) {
-      if (e.getTargetException() instanceof TException) {
-        Throwable t = e.getTargetException();
+    } catch (Throwable t1) {
+      Throwable t = t1;
+      if (t instanceof InvocationTargetException) {
+        t = ((InvocationTargetException) t).getTargetException();
+      }
+
+      if (t instanceof TException) {
         int level = 0;
         while (t != null) {
           LOGGER.error(
@@ -64,31 +68,27 @@ public class SyncThriftClientWithErrorHandler implements MethodInterceptor {
               t.getMessage());
           t = t.getCause();
         }
-        Throwable rootCause = ExceptionUtils.getRootCause(e);
-        // if the exception is SocketException and its error message is Broken pipe, it means that
-        // the remote node may restart and all the connection we cached before should be cleared.
+        ((SyncThriftClient) o).invalidate();
+      }
+      
+      Throwable rootCause = ExceptionUtils.getRootCause(t);
+      // if the exception is SocketException and its error message is Broken pipe, it means that
+      // the remote node may restart and all the connection we cached before should be cleared.
+      LOGGER.error(
+          "root cause message {}, LocalizedMessage {}, ",
+          rootCause.getMessage(),
+          rootCause.getLocalizedMessage(),
+          rootCause);
+      if (rootCause instanceof SocketException
+          && rootCause.getMessage().contains("Broken pipe")) {
         LOGGER.error(
-            "root cause message {}, LocalizedMessage {}, ",
-            rootCause.getMessage(),
-            rootCause.getLocalizedMessage(),
-            rootCause);
-        if (rootCause instanceof SocketException
-            && rootCause.getMessage().contains("Broken pipe")) {
-          LOGGER.error(
-              "Broken pipe error happened in calling method {}, we need to clear all previous cached connection, err: {}",
-              method.getName(),
-              e.getTargetException());
-          ((SyncThriftClient) o).invalidate();
-          ((SyncThriftClient) o).invalidateAll();
-        } else {
-          LOGGER.error(
-              "Error in calling method1 {}, err: {}", method.getName(), e.getTargetException());
-          ((SyncThriftClient) o).invalidate();
-        }
+            "Broken pipe error happened in calling method {}, we need to clear all previous cached connection, err: {}",
+            method.getName(),
+            t);
+        ((SyncThriftClient) o).invalidate();
+        ((SyncThriftClient) o).invalidateAll();
       }
-      throw new TException("Error in calling method2 " + method.getName(), e.getTargetException());
-    } catch (Exception e) {
-      throw new TException("Error in calling method3 " + method.getName(), e);
+      throw new TException("Error in calling method " + method.getName(), t);
     }
   }
 }