You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/03/15 11:01:11 UTC

[incubator-servicecomb-java-chassis] branch master updated: add a exception log when unexpected exceptions happens to give user better understanding

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

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 629be0f  add a exception log when unexpected exceptions happens to give user better understanding
629be0f is described below

commit 629be0f3cfef60b545d868b1b3c355dcd0cc2242
Author: liubao <ba...@huawei.com>
AuthorDate: Fri Mar 2 16:39:13 2018 +0800

    add a exception log when unexpected exceptions happens to give user better understanding
---
 .../foundation/vertx/client/ClientVerticle.java    | 14 +++++++--
 .../transport/highway/HighwayServerVerticle.java   | 11 +++++--
 .../transport/rest/vertx/RestServerVerticle.java   | 34 ++++++++++++----------
 3 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/ClientVerticle.java b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/ClientVerticle.java
index c093773..19e972b 100644
--- a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/ClientVerticle.java
+++ b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/ClientVerticle.java
@@ -17,15 +17,25 @@
 
 package org.apache.servicecomb.foundation.vertx.client;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import io.vertx.core.AbstractVerticle;
 
 public class ClientVerticle<CLIENT_POOL> extends AbstractVerticle {
+  private static final Logger LOGGER = LoggerFactory.getLogger(ClientVerticle.class);
   public static final String CLIENT_MGR = "clientMgr";
 
   @SuppressWarnings("unchecked")
   @Override
   public void start() throws Exception {
-    ClientPoolManager<CLIENT_POOL> clientMgr = (ClientPoolManager<CLIENT_POOL>) config().getValue(CLIENT_MGR);
-    clientMgr.createClientPool();
+    try {
+      ClientPoolManager<CLIENT_POOL> clientMgr = (ClientPoolManager<CLIENT_POOL>) config().getValue(CLIENT_MGR);
+      clientMgr.createClientPool();
+    } catch (Throwable e) {
+      // vert.x got some states that not print error and execute call back in VertexUtils.blockDeploy, we add a log our self.
+      LOGGER.error("", e);
+      throw e;
+    }
   }
 }
diff --git a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerVerticle.java b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerVerticle.java
index e7a694b..9c892b8 100644
--- a/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerVerticle.java
+++ b/transports/transport-highway/src/main/java/org/apache/servicecomb/transport/highway/HighwayServerVerticle.java
@@ -48,9 +48,14 @@ public class HighwayServerVerticle extends AbstractVerticle {
 
   @Override
   public void start(Future<Void> startFuture) throws Exception {
-    super.start();
-
-    startListen(startFuture);
+    try {
+      super.start();
+      startListen(startFuture);
+    } catch (Throwable e) {
+      // vert.x got some states that not print error and execute call back in VertexUtils.blockDeploy, we add a log our self.
+      LOGGER.error("", e);
+      throw e;
+    }
   }
 
   protected void startListen(Future<Void> startFuture) {
diff --git a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java
index 73eab86..6578d72 100644
--- a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java
+++ b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java
@@ -59,23 +59,25 @@ public class RestServerVerticle extends AbstractVerticle {
 
   @Override
   public void start(Future<Void> startFuture) throws Exception {
-    super.start();
-
-    // 如果本地未配置地址,则表示不必监听,只需要作为客户端使用即可
-    if (endpointObject == null) {
-      LOGGER.warn("rest listen address is not configured, will not start.");
-      startFuture.complete();
-      return;
+    try {
+      super.start();
+      // 如果本地未配置地址,则表示不必监听,只需要作为客户端使用即可
+      if (endpointObject == null) {
+        LOGGER.warn("rest listen address is not configured, will not start.");
+        startFuture.complete();
+        return;
+      }
+      Router mainRouter = Router.router(vertx);
+      mountAccessLogHandler(mainRouter);
+      initDispatcher(mainRouter);
+      HttpServer httpServer = createHttpServer();
+      httpServer.requestHandler(mainRouter::accept);
+      startListen(httpServer, startFuture);
+    } catch(Throwable e) {
+      // vert.x got some states that not print error and execute call back in VertexUtils.blockDeploy, we add a log our self.
+      LOGGER.error("", e);
+      throw e;
     }
-
-    Router mainRouter = Router.router(vertx);
-    mountAccessLogHandler(mainRouter);
-    initDispatcher(mainRouter);
-
-    HttpServer httpServer = createHttpServer();
-    httpServer.requestHandler(mainRouter::accept);
-
-    startListen(httpServer, startFuture);
   }
 
   private void mountAccessLogHandler(Router mainRouter) {

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.