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 2021/08/19 07:15:50 UTC

[servicecomb-java-chassis] branch 1.3.x updated: [SCB-2206][SCB-2221][SCB-2241]print message null when exception is InvocationTargetException, add executor in edge service, fix microservice.basePaths data type bug (#2519)

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

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


The following commit(s) were added to refs/heads/1.3.x by this push:
     new a2d7dba  [SCB-2206][SCB-2221][SCB-2241]print message null when exception is InvocationTargetException,add executor in edge service,fix microservice.basePaths data type bug (#2519)
a2d7dba is described below

commit a2d7dbaed097f5cb5e3a2681824aace61f8874c9
Author: david6969xin <86...@users.noreply.github.com>
AuthorDate: Thu Aug 19 15:15:44 2021 +0800

    [SCB-2206][SCB-2221][SCB-2241]print message null when exception is InvocationTargetException,add executor in edge service,fix microservice.basePaths data type bug (#2519)
---
 .../servicecomb/core/executor/ExecutorManager.java       |  6 ++++++
 .../serviceregistry/config/ConfigurePropertyUtils.java   | 16 +++++++---------
 .../config/TestConfigurePropertyUtils.java               |  4 ++--
 .../swagger/engine/SwaggerProducerOperation.java         | 11 +++++------
 4 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/core/src/main/java/org/apache/servicecomb/core/executor/ExecutorManager.java b/core/src/main/java/org/apache/servicecomb/core/executor/ExecutorManager.java
index 27dc7e3..7771182 100644
--- a/core/src/main/java/org/apache/servicecomb/core/executor/ExecutorManager.java
+++ b/core/src/main/java/org/apache/servicecomb/core/executor/ExecutorManager.java
@@ -59,6 +59,12 @@ public final class ExecutorManager {
       return executor;
     }
 
+    // microservice级别
+    executor = findByKey(KEY_EXECUTORS_PREFIX + operationMeta.getMicroserviceName());
+    if (executor != null) {
+      return executor;
+    }
+
     executor = findByKey(KEY_EXECUTORS_DEFAULT);
     if (executor != null) {
       return executor;
diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ConfigurePropertyUtils.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ConfigurePropertyUtils.java
index 9d2ca05..12573a4 100644
--- a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ConfigurePropertyUtils.java
+++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/config/ConfigurePropertyUtils.java
@@ -17,7 +17,6 @@
 
 package org.apache.servicecomb.serviceregistry.config;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -28,8 +27,11 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.servicecomb.serviceregistry.api.Const;
 import org.apache.servicecomb.serviceregistry.api.registry.BasePath;
 
+import com.fasterxml.jackson.databind.type.TypeFactory;
 import com.netflix.config.DynamicPropertyFactory;
 
+import io.vertx.core.json.jackson.DatabindCodec;
+
 public final class ConfigurePropertyUtils {
   private ConfigurePropertyUtils() {
   }
@@ -60,14 +62,10 @@ public final class ConfigurePropertyUtils {
 
   @SuppressWarnings("unchecked")
   public static List<BasePath> getMicroservicePaths(Configuration configuration) {
-    List<BasePath> basePaths = new ArrayList<>();
-    for (Object path : configuration.getList("service_description.paths")) {
-      BasePath basePath = new BasePath();
-      Map<String, ?> pathMap = (Map<String, ?>) path;
-      basePath.setPath(buildPath((String) pathMap.get("path")));
-      basePath.setProperty((Map<String, String>) pathMap.get("property"));
-      basePaths.add(basePath);
-    }
+    List<Object> configPaths = configuration.getList("service_description.paths");
+    List<BasePath> basePaths = DatabindCodec.mapper()
+        .convertValue(configPaths, TypeFactory.defaultInstance().constructCollectionType(List.class, BasePath.class));
+    basePaths.forEach(basePath -> basePath.setPath(buildPath(basePath.getPath())));
     return basePaths;
   }
 
diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestConfigurePropertyUtils.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestConfigurePropertyUtils.java
index a1778ee..ed8b8a5 100644
--- a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestConfigurePropertyUtils.java
+++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/config/TestConfigurePropertyUtils.java
@@ -42,12 +42,12 @@ public class TestConfigurePropertyUtils {
     List<BasePath> paths = ConfigurePropertyUtils.getMicroservicePaths(configuration);
     Assert.assertEquals(2, paths.size());
     Assert.assertEquals(paths.get(0).getPath(), "/test1/testpath");
-    Assert.assertEquals(paths.get(0).getProperty().get("checksession"), false);
+    Assert.assertEquals(paths.get(0).getProperty().get("checksession"), "false");
 
     System.setProperty(Const.URL_PREFIX, "/webroot");
     paths = ConfigurePropertyUtils.getMicroservicePaths(configuration);
     Assert.assertEquals(2, paths.size());
     Assert.assertEquals(paths.get(0).getPath(), "/webroot/test1/testpath");
-    Assert.assertEquals(paths.get(0).getProperty().get("checksession"), false);
+    Assert.assertEquals(paths.get(0).getProperty().get("checksession"), "false");
   }
 }
diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducerOperation.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducerOperation.java
index 6392bce..b715abd 100644
--- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducerOperation.java
+++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/engine/SwaggerProducerOperation.java
@@ -21,15 +21,14 @@ import java.lang.reflect.Method;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
 
-import javax.ws.rs.core.Response.Status;
 
+import org.apache.servicecomb.foundation.common.utils.ExceptionUtils;
 import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
 import org.apache.servicecomb.swagger.invocation.AsyncResponse;
 import org.apache.servicecomb.swagger.invocation.Response;
 import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
 import org.apache.servicecomb.swagger.invocation.arguments.producer.ProducerArgumentsMapper;
 import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
-import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData;
 import org.apache.servicecomb.swagger.invocation.exception.ExceptionFactory;
 import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
 import org.apache.servicecomb.swagger.invocation.extension.ProducerInvokeExtension;
@@ -152,9 +151,9 @@ public class SwaggerProducerOperation {
         asyncResp.handle(processException(invocation, ex));
       });
     } catch (Throwable e) {
-      if (shouldPrintErrorLog(e)){
+      if (shouldPrintErrorLog(e)) {
         LOGGER.error("unexpected error operation={}, message={}",
-            invocation.getInvocationQualifiedName(), e.getMessage());
+            invocation.getInvocationQualifiedName(), ExceptionUtils.getExceptionMessageWithoutTrace(e));
       }
       invocation.onBusinessMethodFinish();
       invocation.onBusinessFinish();
@@ -185,9 +184,9 @@ public class SwaggerProducerOperation {
       invocation.onBusinessMethodFinish();
       invocation.onBusinessFinish();
     } catch (Throwable e) {
-      if (shouldPrintErrorLog(e)){
+      if (shouldPrintErrorLog(e)) {
         LOGGER.error("unexpected error operation={}, message={}",
-            invocation.getInvocationQualifiedName(), e.getMessage());
+            invocation.getInvocationQualifiedName(), ExceptionUtils.getExceptionMessageWithoutTrace(e));
       }
       invocation.onBusinessMethodFinish();
       invocation.onBusinessFinish();