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/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new de50f7b  [SCB-2106]add an exception handler for vert.x http server 
starup failure (#2009)
de50f7b is described below

commit de50f7b689ed4be08dcceca02c5bda376dd8625d
Author: liuguangrong <[email protected]>
AuthorDate: Tue Oct 27 11:37:33 2020 +0800

    [SCB-2106]add an exception handler for vert.x http server starup failure 
(#2009)
    
    * 添加钩子
    
    * 添加钩子
    
    Co-authored-by: liuguangrong <[email protected]>
---
 .../rest/vertx/HttpServerExceptionHandler.java     | 24 ++++++++++++++++++++++
 .../transport/rest/vertx/RestServerVerticle.java   |  5 +++++
 2 files changed, 29 insertions(+)

diff --git 
a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/HttpServerExceptionHandler.java
 
b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/HttpServerExceptionHandler.java
new file mode 100644
index 0000000..9829f3c
--- /dev/null
+++ 
b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/HttpServerExceptionHandler.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.transport.rest.vertx;
+
+import io.vertx.core.Handler;
+import org.apache.servicecomb.foundation.common.utils.SPIOrder;
+
+public interface HttpServerExceptionHandler extends Handler<Throwable>, 
SPIOrder {
+}
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 5c6f3e1..0a8e581 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
@@ -109,6 +109,8 @@ public class RestServerVerticle extends AbstractVerticle {
           endpointMetric.onRejectByConnectionLimit();
         }
       });
+      List<HttpServerExceptionHandler> httpServerExceptionHandlers =
+          SPIServiceUtils.getAllService(HttpServerExceptionHandler.class);
       httpServer.exceptionHandler(e -> {
         if (e instanceof ClosedChannelException) {
           // This is quite normal in between browser and ege, so do not print 
out.
@@ -116,6 +118,9 @@ public class RestServerVerticle extends AbstractVerticle {
         } else {
           LOGGER.error("Unexpected error in server.{}", 
ExceptionUtils.getExceptionMessageWithoutTrace(e));
         }
+        httpServerExceptionHandlers.forEach(httpServerExceptionHandler -> {
+          httpServerExceptionHandler.handle(e);
+        });
       });
       startListen(httpServer, startFuture);
     } catch (Throwable e) {

Reply via email to