You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by wu...@apache.org on 2020/11/27 02:16:04 UTC

[servicecomb-java-chassis] branch master updated (4f58467 -> f33483f)

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

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


    from 4f58467  Scb 2128 support dynamic single value enum (#2080)
     new 96afde5  [#2081]add a test case for query with List<String>
     new c3e0a57  [SCB-2131]when timeout exception, connect closed will trigger asynchronous callback
     new f33483f  [SCB-2131]fix review comment

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../jaxrs/client/TestQueryParamWithListSchema.java | 154 +++++++++++++++++++++
 .../jaxrs/server/QueryParamWithListSchema.java     |  62 +++++++++
 .../rest/client/http/RestClientInvocation.java     |  16 ++-
 3 files changed, 228 insertions(+), 4 deletions(-)
 create mode 100644 demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/TestQueryParamWithListSchema.java
 create mode 100644 demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/QueryParamWithListSchema.java


[servicecomb-java-chassis] 02/03: [SCB-2131]when timeout exception, connect closed will trigger asynchronous callback

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c3e0a57c5b67069d661636c4b9f045041dc2afd5
Author: liubao <bi...@qq.com>
AuthorDate: Thu Nov 26 21:16:15 2020 +0800

    [SCB-2131]when timeout exception, connect closed will trigger asynchronous callback
---
 .../transport/rest/client/http/RestClientInvocation.java | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java
index 838131d..18f6f58 100644
--- a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java
+++ b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java
@@ -84,6 +84,8 @@ public class RestClientInvocation {
 
   private Handler<Throwable> throwableHandler = e -> fail((ConnectionBase) clientRequest.connection(), e);
 
+  private boolean alreadyFailed = false;
+
   public RestClientInvocation(HttpClientWithContext httpClientWithContext, List<HttpClientFilter> httpClientFilters) {
     this.httpClientWithContext = httpClientWithContext;
     this.httpClientFilters = httpClientFilters;
@@ -115,8 +117,10 @@ public class RestClientInvocation {
     }
 
     clientRequest.exceptionHandler(e -> {
-      invocation.getTraceIdLogger().error(LOGGER, "Failed to send request, local:{}, remote:{}, message={}.",
-          getLocalAddress(), ipPort.getSocketAddress(), ExceptionUtils.getExceptionMessageWithoutTrace(e));
+      invocation.getTraceIdLogger()
+          .error(LOGGER, "Failed to send request, alreadyFailed:{}, local:{}, remote:{}, message={}.",
+              alreadyFailed, getLocalAddress(), ipPort.getSocketAddress(),
+              ExceptionUtils.getExceptionMessageWithoutTrace(e));
       throwableHandler.handle(e);
     });
 
@@ -129,7 +133,9 @@ public class RestClientInvocation {
         restClientRequest.end();
       } catch (Throwable e) {
         invocation.getTraceIdLogger().error(LOGGER,
-            "send http request failed, local:{}, remote: {}, message={}.", getLocalAddress(), ipPort
+            "send http request failed, alreadyFailed:{}, local:{}, remote: {}, message={}.",
+            alreadyFailed,
+            getLocalAddress(), ipPort
             , ExceptionUtils.getExceptionMessageWithoutTrace(e));
         fail((ConnectionBase) clientRequest.connection(), e);
       }
@@ -249,10 +255,12 @@ public class RestClientInvocation {
   }
 
   protected void fail(ConnectionBase connection, Throwable e) {
-    if (invocation.isFinished()) {
+    if (alreadyFailed) {
       return;
     }
 
+    alreadyFailed = true;
+
     InvocationStageTrace stageTrace = invocation.getInvocationStageTrace();
     // connection maybe null when exception happens such as ssl handshake failure
     if (connection != null) {


[servicecomb-java-chassis] 03/03: [SCB-2131]fix review comment

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f33483f6ceea68ae36faeb15da9b18f48f2f2b06
Author: liubao <bi...@qq.com>
AuthorDate: Fri Nov 27 09:43:46 2020 +0800

    [SCB-2131]fix review comment
---
 .../jaxrs/client/TestQueryParamWithListSchema.java | 40 +++++++++++-----------
 .../jaxrs/server/QueryParamWithListSchema.java     | 10 +++---
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/TestQueryParamWithListSchema.java b/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/TestQueryParamWithListSchema.java
index 84ab80a..40c9b8d 100644
--- a/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/TestQueryParamWithListSchema.java
+++ b/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/TestQueryParamWithListSchema.java
@@ -61,16 +61,16 @@ public class TestQueryParamWithListSchema implements CategorizedTestCase {
   }
 
   private void testCSVRest() {
-    TestMgr.check("[]",
+    TestMgr.check("0:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?", String.class));
   }
 
   private void testSSV() {
-    TestMgr.check("[1, 2]",
+    TestMgr.check("2:[1, 2]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?queryList=1%202", String.class));
-    TestMgr.check("[, ]",
+    TestMgr.check("2:[, ]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?queryList=%20", String.class));
-    TestMgr.check("[]",
+    TestMgr.check("1:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?queryList=", String.class));
   }
 
@@ -80,17 +80,17 @@ public class TestQueryParamWithListSchema implements CategorizedTestCase {
   }
 
   private void testTSVRest() {
-    TestMgr.check("[]",
+    TestMgr.check("0:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListTSV?", String.class));
   }
 
   private void testTSV() {
-    TestMgr.check("[1, 2]",
+    TestMgr.check("2:[1, 2]",
         restTemplate
             .getForObject("cse://jaxrs/queryList/queryListTSV?queryList={1}", String.class, "1\t2"));
-    TestMgr.check("[, ]",
+    TestMgr.check("2:[, ]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListTSV?queryList={1}", String.class, "\t"));
-    TestMgr.check("[]",
+    TestMgr.check("1:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListTSV?queryList=", String.class));
   }
 
@@ -100,17 +100,17 @@ public class TestQueryParamWithListSchema implements CategorizedTestCase {
   }
 
   private void testPipesRest() {
-    TestMgr.check("[]",
+    TestMgr.check("0:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListPIPES?", String.class));
   }
 
   private void testPipes() {
-    TestMgr.check("[1, 2]",
+    TestMgr.check("2:[1, 2]",
         restTemplate
             .getForObject("cse://jaxrs/queryList/queryListPIPES?queryList={1}", String.class, "1|2"));
-    TestMgr.check("[, ]",
+    TestMgr.check("2:[, ]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListPIPES?queryList={1}", String.class, "|"));
-    TestMgr.check("[]",
+    TestMgr.check("1:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListPIPES?queryList=", String.class));
   }
 
@@ -120,16 +120,16 @@ public class TestQueryParamWithListSchema implements CategorizedTestCase {
   }
 
   private void testSSVRest() {
-    TestMgr.check("[]",
+    TestMgr.check("0:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?", String.class));
   }
 
   private void testCSV() {
-    TestMgr.check("[1, 2]",
+    TestMgr.check("2:[1, 2]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?queryList=1,2", String.class));
-    TestMgr.check("[, ]",
+    TestMgr.check("2:[, ]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?queryList=,", String.class));
-    TestMgr.check("[]",
+    TestMgr.check("1:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?queryList=", String.class));
   }
 
@@ -139,16 +139,16 @@ public class TestQueryParamWithListSchema implements CategorizedTestCase {
   }
 
   private void testMultiRest() {
-    TestMgr.check("[]",
+    TestMgr.check("0:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?", String.class));
   }
 
   private void testMulti() {
-    TestMgr.check("[1, 2]",
+    TestMgr.check("2:[1, 2]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?queryList=1&queryList=2", String.class));
-    TestMgr.check("[, ]",
+    TestMgr.check("2:[, ]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?queryList=&queryList=", String.class));
-    TestMgr.check("[]",
+    TestMgr.check("1:[]",
         restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?queryList=", String.class));
   }
 }
diff --git a/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/QueryParamWithListSchema.java b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/QueryParamWithListSchema.java
index 1f0b10b..c1fcfd9 100644
--- a/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/QueryParamWithListSchema.java
+++ b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/QueryParamWithListSchema.java
@@ -33,30 +33,30 @@ public class QueryParamWithListSchema {
   @Path("queryListCSV")
   @GET
   public String queryListCSV(@ApiParam(collectionFormat = "csv") @QueryParam("queryList") List<String> queryList) {
-    return queryList == null ? "null" : queryList.toString();
+    return queryList == null ? "null" : queryList.size() + ":" + queryList.toString();
   }
 
   @Path("queryListSSV")
   @GET
   public String queryListSSV(@ApiParam(collectionFormat = "ssv") @QueryParam("queryList") List<String> queryList) {
-    return queryList == null ? "null" : queryList.toString();
+    return queryList == null ? "null" : queryList.size() + ":" + queryList.toString();
   }
 
   @Path("queryListTSV")
   @GET
   public String queryListTSV(@ApiParam(collectionFormat = "tsv") @QueryParam("queryList") List<String> queryList) {
-    return queryList == null ? "null" : queryList.toString();
+    return queryList == null ? "null" : queryList.size() + ":" + queryList.toString();
   }
 
   @Path("queryListPIPES")
   @GET
   public String queryListPIPES(@ApiParam(collectionFormat = "pipes") @QueryParam("queryList") List<String> queryList) {
-    return queryList == null ? "null" : queryList.toString();
+    return queryList == null ? "null" : queryList.size() + ":" + queryList.toString();
   }
 
   @Path("queryListMULTI")
   @GET
   public String queryListMULTI(@ApiParam(collectionFormat = "multi") @QueryParam("queryList") List<String> queryList) {
-    return queryList == null ? "null" : queryList.toString();
+    return queryList == null ? "null" : queryList.size() + ":" + queryList.toString();
   }
 }


[servicecomb-java-chassis] 01/03: [#2081]add a test case for query with List

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 96afde535ff4acd6f224a40a636f15dddbd4baf6
Author: liubao <bi...@qq.com>
AuthorDate: Thu Nov 26 18:02:31 2020 +0800

    [#2081]add a test case for query with List<String>
---
 .../jaxrs/client/TestQueryParamWithListSchema.java | 154 +++++++++++++++++++++
 .../jaxrs/server/QueryParamWithListSchema.java     |  62 +++++++++
 2 files changed, 216 insertions(+)

diff --git a/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/TestQueryParamWithListSchema.java b/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/TestQueryParamWithListSchema.java
new file mode 100644
index 0000000..84ab80a
--- /dev/null
+++ b/demo/demo-jaxrs/jaxrs-client/src/main/java/org/apache/servicecomb/demo/jaxrs/client/TestQueryParamWithListSchema.java
@@ -0,0 +1,154 @@
+/*
+ * 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.demo.jaxrs.client;
+
+import org.apache.servicecomb.demo.CategorizedTestCase;
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+@Component
+public class TestQueryParamWithListSchema implements CategorizedTestCase {
+  private RestTemplate restTemplate = RestTemplateBuilder.create();
+
+  @Override
+  public void testAllTransport() throws Exception {
+    testMulti();
+    testCSV();
+    testSSV();
+    testTSV();
+    testPipes();
+  }
+
+  @Override
+  public void testRestTransport() throws Exception {
+    testMultiRest();
+    testCSVRest();
+    testSSVRest();
+    testTSVRest();
+    testPipesRest();
+  }
+
+  @Override
+  // highway do not handle empty/default/null
+  public void testHighwayTransport() throws Exception {
+    testMultiHighway();
+    testCSVHighway();
+    testSSVHighway();
+    testTSVHighway();
+    testPipesHighway();
+  }
+
+  private void testCSVHighway() {
+    TestMgr.check("null",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?", String.class));
+  }
+
+  private void testCSVRest() {
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?", String.class));
+  }
+
+  private void testSSV() {
+    TestMgr.check("[1, 2]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?queryList=1%202", String.class));
+    TestMgr.check("[, ]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?queryList=%20", String.class));
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?queryList=", String.class));
+  }
+
+  private void testTSVHighway() {
+    TestMgr.check("null",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListTSV?", String.class));
+  }
+
+  private void testTSVRest() {
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListTSV?", String.class));
+  }
+
+  private void testTSV() {
+    TestMgr.check("[1, 2]",
+        restTemplate
+            .getForObject("cse://jaxrs/queryList/queryListTSV?queryList={1}", String.class, "1\t2"));
+    TestMgr.check("[, ]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListTSV?queryList={1}", String.class, "\t"));
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListTSV?queryList=", String.class));
+  }
+
+  private void testPipesHighway() {
+    TestMgr.check("null",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListPIPES?", String.class));
+  }
+
+  private void testPipesRest() {
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListPIPES?", String.class));
+  }
+
+  private void testPipes() {
+    TestMgr.check("[1, 2]",
+        restTemplate
+            .getForObject("cse://jaxrs/queryList/queryListPIPES?queryList={1}", String.class, "1|2"));
+    TestMgr.check("[, ]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListPIPES?queryList={1}", String.class, "|"));
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListPIPES?queryList=", String.class));
+  }
+
+  private void testSSVHighway() {
+    TestMgr.check("null",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?", String.class));
+  }
+
+  private void testSSVRest() {
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListSSV?", String.class));
+  }
+
+  private void testCSV() {
+    TestMgr.check("[1, 2]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?queryList=1,2", String.class));
+    TestMgr.check("[, ]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?queryList=,", String.class));
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListCSV?queryList=", String.class));
+  }
+
+  private void testMultiHighway() {
+    TestMgr.check("null",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?", String.class));
+  }
+
+  private void testMultiRest() {
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?", String.class));
+  }
+
+  private void testMulti() {
+    TestMgr.check("[1, 2]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?queryList=1&queryList=2", String.class));
+    TestMgr.check("[, ]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?queryList=&queryList=", String.class));
+    TestMgr.check("[]",
+        restTemplate.getForObject("cse://jaxrs/queryList/queryListMULTI?queryList=", String.class));
+  }
+}
diff --git a/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/QueryParamWithListSchema.java b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/QueryParamWithListSchema.java
new file mode 100644
index 0000000..1f0b10b
--- /dev/null
+++ b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/QueryParamWithListSchema.java
@@ -0,0 +1,62 @@
+/*
+ * 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.demo.jaxrs.server;
+
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+
+import io.swagger.annotations.ApiParam;
+
+@RestSchema(schemaId = "QueryParamWithListSchema")
+@Path("/queryList")
+public class QueryParamWithListSchema {
+  @Path("queryListCSV")
+  @GET
+  public String queryListCSV(@ApiParam(collectionFormat = "csv") @QueryParam("queryList") List<String> queryList) {
+    return queryList == null ? "null" : queryList.toString();
+  }
+
+  @Path("queryListSSV")
+  @GET
+  public String queryListSSV(@ApiParam(collectionFormat = "ssv") @QueryParam("queryList") List<String> queryList) {
+    return queryList == null ? "null" : queryList.toString();
+  }
+
+  @Path("queryListTSV")
+  @GET
+  public String queryListTSV(@ApiParam(collectionFormat = "tsv") @QueryParam("queryList") List<String> queryList) {
+    return queryList == null ? "null" : queryList.toString();
+  }
+
+  @Path("queryListPIPES")
+  @GET
+  public String queryListPIPES(@ApiParam(collectionFormat = "pipes") @QueryParam("queryList") List<String> queryList) {
+    return queryList == null ? "null" : queryList.toString();
+  }
+
+  @Path("queryListMULTI")
+  @GET
+  public String queryListMULTI(@ApiParam(collectionFormat = "multi") @QueryParam("queryList") List<String> queryList) {
+    return queryList == null ? "null" : queryList.toString();
+  }
+}