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 2020/12/01 12:22:41 UTC

[servicecomb-java-chassis] branch master updated: [SCB-2138] fix 3rd service register problem (#2095)

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 041bc83  [SCB-2138] fix 3rd service register problem (#2095)
041bc83 is described below

commit 041bc83d31975bc916b0be0e576e300e24430f7e
Author: wujimin <wu...@huawei.com>
AuthorDate: Tue Dec 1 20:22:32 2020 +0800

    [SCB-2138] fix 3rd service register problem (#2095)
---
 .../org/apache/servicecomb/common/rest/RestEngineSchemaListener.java | 5 +++++
 .../apache/servicecomb/common/rest/definition/RestOperationMeta.java | 3 ++-
 .../org/apache/servicecomb/core/registry/ThirdServiceRegister.java   | 2 +-
 .../servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java      | 4 +++-
 .../servicecomb/foundation/vertx/executor/VertxContextExecutor.java  | 4 ++++
 .../apache/servicecomb/it/testcase/TestRestVertxTransportConfig.java | 3 ++-
 6 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/RestEngineSchemaListener.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/RestEngineSchemaListener.java
index 50bcde5..51d68a8 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/RestEngineSchemaListener.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/RestEngineSchemaListener.java
@@ -29,6 +29,11 @@ import com.google.common.eventbus.Subscribe;
 
 public class RestEngineSchemaListener implements BootListener {
   @Override
+  public int getOrder() {
+    return -10000;
+  }
+
+  @Override
   public void onBeforeRegistry(BootEvent event) {
     createServicePathManager(event.getScbEngine().getProducerMicroserviceMeta())
         .buildProducerPaths();
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
index 715eb24..011a5a3 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
@@ -259,7 +259,8 @@ public class RestOperationMeta {
         }
         ProduceProcessor processor = ProduceProcessorManager.INSTANCE.findProcessor(produce, serialViewClass);
         if (processor == null) {
-          LOGGER.error("produce {} is not supported", produce);
+          LOGGER.error("produce {} is not supported, operation={}.", produce,
+              operationMeta.getMicroserviceQualifiedName());
           continue;
         }
         this.produceProcessorMap.put(produce, processor);
diff --git a/core/src/main/java/org/apache/servicecomb/core/registry/ThirdServiceRegister.java b/core/src/main/java/org/apache/servicecomb/core/registry/ThirdServiceRegister.java
index 3c76938..c3053ee 100644
--- a/core/src/main/java/org/apache/servicecomb/core/registry/ThirdServiceRegister.java
+++ b/core/src/main/java/org/apache/servicecomb/core/registry/ThirdServiceRegister.java
@@ -136,7 +136,7 @@ public abstract class ThirdServiceRegister implements BootListener, EnvironmentA
   }
 
   @Override
-  public void onAfterRegistry(BootEvent event) {
+  public void onBeforeRegistry(BootEvent event) {
     appId = event.getScbEngine().getAppId();
     registerMicroserviceMapping();
   }
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java
index 44cb66e..df3caa7 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java
@@ -15,6 +15,8 @@
  */
 package org.apache.servicecomb.demo.springmvc.client;
 
+import static javax.ws.rs.core.Response.Status.REQUEST_URI_TOO_LONG;
+
 import org.apache.servicecomb.demo.CategorizedTestCase;
 import org.apache.servicecomb.demo.TestMgr;
 import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
@@ -45,7 +47,7 @@ public class TestMaxHttpUrlLength implements CategorizedTestCase {
           String.class);
       TestMgr.check(true, false);
     } catch (InvocationException e) {
-      TestMgr.check(414, e.getStatusCode());
+      TestMgr.check(REQUEST_URI_TOO_LONG.getStatusCode(), e.getStatusCode());
     }
   }
 
diff --git a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/executor/VertxContextExecutor.java b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/executor/VertxContextExecutor.java
index a7157ba..1d85fb3 100644
--- a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/executor/VertxContextExecutor.java
+++ b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/executor/VertxContextExecutor.java
@@ -23,6 +23,10 @@ import io.vertx.core.Context;
 import io.vertx.core.Vertx;
 
 public class VertxContextExecutor implements Executor {
+  public static VertxContextExecutor create(Vertx vertx) {
+    return new VertxContextExecutor(vertx.getOrCreateContext());
+  }
+
   public static VertxContextExecutor create(Context context) {
     return new VertxContextExecutor(context);
   }
diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestRestVertxTransportConfig.java b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestRestVertxTransportConfig.java
index 96531e9..7333e70 100644
--- a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestRestVertxTransportConfig.java
+++ b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestRestVertxTransportConfig.java
@@ -17,6 +17,7 @@
 
 package org.apache.servicecomb.it.testcase;
 
+import static javax.ws.rs.core.Response.Status.REQUEST_URI_TOO_LONG;
 import static org.junit.Assert.fail;
 
 import org.apache.servicecomb.foundation.common.utils.ExceptionUtils;
@@ -66,7 +67,7 @@ public class TestRestVertxTransportConfig {
       consumers.getIntf().testMaxInitialLineLength(q);
       fail("an exception is expected!");
     } catch (InvocationException e) {
-      Assert.assertEquals(414, e.getStatusCode());
+      Assert.assertEquals(REQUEST_URI_TOO_LONG.getStatusCode(), e.getStatusCode());
     }
   }