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/03/20 00:32:47 UTC

[servicecomb-java-chassis] 01/02: [SCB-1798]InvokerUtils support specify response type

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

commit cf5ef8b733d4e77d6fb622743897d76501a8f6fd
Author: liubao <bi...@qq.com>
AuthorDate: Thu Mar 19 17:42:28 2020 +0800

    [SCB-1798]InvokerUtils support specify response type
---
 .../core/provider/consumer/InvokerUtils.java       |  89 ++++++++++--
 .../servicecomb/demo/crossapp/CrossappClient.java  |   1 +
 .../servicecomb/demo/pojo/client/PojoClient.java   |   1 +
 .../servicecomb/demo/pojo/client/TestWeakPojo.java |   1 +
 .../demo/pojo/client/invoker/ClientModel.java      |  39 ++++++
 .../pojo/client/invoker/TestInvokerEndpoint.java   | 153 +++++++++++++++++++++
 .../demo/pojo/server/invoker/InvokerEndpoint.java  |  27 ++++
 .../demo/pojo/server/invoker/ServerModel.java      |  39 ++++++
 .../demo/pojo/client/PojoClientTest.java           |   1 +
 .../demo/springmvc/client/TestWeakSpringmvc.java   |   1 +
 10 files changed, 338 insertions(+), 14 deletions(-)

diff --git a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
index 9e0b976..59f1210 100644
--- a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
+++ b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
@@ -17,8 +17,11 @@
 
 package org.apache.servicecomb.core.provider.consumer;
 
+import java.lang.reflect.Type;
 import java.util.Map;
 
+import javax.ws.rs.core.Response.Status;
+
 import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.core.SCBEngine;
 import org.apache.servicecomb.core.definition.MicroserviceMeta;
@@ -30,19 +33,46 @@ import org.apache.servicecomb.swagger.invocation.Response;
 import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
 import org.apache.servicecomb.swagger.invocation.exception.ExceptionFactory;
 import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+import org.apache.servicecomb.swagger.invocation.response.ResponsesMeta;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
 public final class InvokerUtils {
   private static final Logger LOGGER = LoggerFactory.getLogger(InvokerUtils.class);
 
-  public static Object syncInvoke(String microserviceName, String schemaId, String operationId,
-      Map<String, Object> swaggerArguments) {
-    return syncInvoke(microserviceName, null, null, schemaId, operationId, swaggerArguments);
+  @SuppressWarnings({"unchecked"})
+  public static <T> T syncInvoke(String microserviceName, String microserviceVersion, String transport,
+      String schemaId, String operationId, Map<String, Object> swaggerArguments, Type responseType) {
+    Invocation invocation = createInvocation(microserviceName, microserviceVersion, transport, schemaId, operationId,
+        swaggerArguments, responseType);
+    return (T) syncInvoke(invocation);
   }
 
-  public static Object syncInvoke(String microserviceName, String microserviceVersion, String transport,
-      String schemaId, String operationId, Map<String, Object> swaggerArguments) {
+  public static void reactiveInvoke(String microserviceName, String microserviceVersion, String transport,
+      String schemaId, String operationId, Map<String, Object> swaggerArguments, Type responseType,
+      AsyncResponse asyncResp) {
+    Invocation invocation = createInvocation(microserviceName, microserviceVersion, transport, schemaId, operationId,
+        swaggerArguments, responseType);
+    reactiveInvoke(invocation, asyncResp);
+  }
+
+  public static <T> T syncInvoke(String microserviceName, String schemaId, String operationId,
+      Map<String, Object> swaggerArguments, Type responseType) {
+    return syncInvoke(microserviceName, null, null,
+        schemaId, operationId, swaggerArguments, responseType);
+  }
+
+  public static void reactiveInvoke(String microserviceName, String schemaId, String operationId,
+      Map<String, Object> swaggerArguments, Type responseType,
+      AsyncResponse asyncResp) {
+    reactiveInvoke(microserviceName, null, null,
+        schemaId, operationId, swaggerArguments, responseType, asyncResp);
+  }
+
+  private static Invocation createInvocation(String microserviceName, String microserviceVersion, String transport,
+      String schemaId, String operationId, Map<String, Object> swaggerArguments, Type responseType) {
     MicroserviceReferenceConfig microserviceReferenceConfig = SCBEngine.getInstance()
         .createMicroserviceReferenceConfig(microserviceName, microserviceVersion);
     MicroserviceMeta microserviceMeta = microserviceReferenceConfig.getLatestMicroserviceMeta();
@@ -51,11 +81,47 @@ public final class InvokerUtils {
 
     ReferenceConfig referenceConfig = microserviceReferenceConfig.createReferenceConfig(transport, operationMeta);
     Invocation invocation = InvocationFactory.forConsumer(referenceConfig, operationMeta, swaggerArguments);
-    return syncInvoke(invocation);
+    setInvocationResponseType(invocation, responseType);
+    return invocation;
+  }
+
+  private static void setInvocationResponseType(Invocation invocation, Type responseType) {
+    if (responseType != null) {
+      ResponsesMeta responsesMeta = new ResponsesMeta();
+      invocation.getOperationMeta().getResponsesMeta().cloneTo(responsesMeta);
+      responsesMeta.getResponseMap().put(Status.OK.getStatusCode(),
+          TypeFactory.defaultInstance().constructType(responseType));
+      invocation.setResponsesMeta(responsesMeta);
+    }
+  }
+
+  /**
+   *
+   * use of this method , the response type can not be determined.
+   * use {@link #syncInvoke(String, String, String, Map, Type)} instead.
+   *
+   */
+  @Deprecated
+  public static Object syncInvoke(String microserviceName, String schemaId, String operationId,
+      Map<String, Object> swaggerArguments) {
+    return syncInvoke(microserviceName, null, null, schemaId, operationId, swaggerArguments);
   }
 
   /**
-   * it's a internal API, caller make sure already invoked SCBEngine.ensureStatusUp
+   *
+   * use of this method , the response type can not be determined.
+   * use {@link #syncInvoke(String, String, String, String, String, Map, Type)} instead.
+   *
+   */
+  @Deprecated
+  public static Object syncInvoke(String microserviceName, String microserviceVersion, String transport,
+      String schemaId, String operationId, Map<String, Object> swaggerArguments) {
+    return syncInvoke(microserviceName, microserviceVersion, transport, schemaId, operationId, swaggerArguments,
+        null);
+  }
+
+  /**
+   * This is an internal API, caller make sure already invoked SCBEngine.ensureStatusUp
    * @param invocation
    * @return contract result
    * @throws InvocationException
@@ -69,7 +135,7 @@ public final class InvokerUtils {
   }
 
   /**
-   * it's a internal API, caller make sure already invoked SCBEngine.ensureStatusUp
+   * This is an internal API, caller make sure already invoked SCBEngine.ensureStatusUp
    * @param invocation
    * @return servicecomb response object
    */
@@ -100,7 +166,7 @@ public final class InvokerUtils {
   }
 
   /**
-   * it's a internal API, caller make sure already invoked SCBEngine.ensureStatusUp
+   * This is an internal API, caller make sure already invoked SCBEngine.ensureStatusUp
    * @param invocation
    * @param asyncResp
    */
@@ -132,9 +198,4 @@ public final class InvokerUtils {
       asyncResp.handle(response);
     }
   }
-
-  @Deprecated
-  public static Object invoke(Invocation invocation) {
-    return syncInvoke(invocation);
-  }
 }
diff --git a/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappClient.java b/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappClient.java
index 9df1546..9261620 100644
--- a/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappClient.java
+++ b/demo/demo-crossapp/crossapp-client/src/main/java/org/apache/servicecomb/demo/crossapp/CrossappClient.java
@@ -50,6 +50,7 @@ public class CrossappClient {
     System.setProperty("sun.net.http.allowRestrictedHeaders", "false");
   }
 
+  @SuppressWarnings({"deprecation"})
   public static void run() {
     Object result = InvokerUtils.syncInvoke("appServer:appService", "helloworld", "sayHello", null);
     TestMgr.check("hello world", result);
diff --git a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClient.java b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClient.java
index a302b38..31c7a24 100644
--- a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClient.java
+++ b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClient.java
@@ -259,6 +259,7 @@ public class PojoClient {
     TestMgr.check("User [name=nameA,  users count:0, age=100, index=1]", result);
   }
 
+  @SuppressWarnings({"deprecation"})
   private static void testCommonInvoke(String transport) {
     Map<String, Object> arguments = new HashMap<>();
     arguments.put("index", 2);
diff --git a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/TestWeakPojo.java b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/TestWeakPojo.java
index 1ab7f58..8b1e620 100644
--- a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/TestWeakPojo.java
+++ b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/TestWeakPojo.java
@@ -178,6 +178,7 @@ public class TestWeakPojo implements CategorizedTestCase {
     TestMgr.check("hello", nameListResult.get(0).get(0));
   }
 
+  @SuppressWarnings({"deprecation"})
   private void testDiffName() {
     TestMgr.check(7, diffNames.differentName(2, 3));
     TestMgr.check(8, diffNames2.differentName(2, 3));
diff --git a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/invoker/ClientModel.java b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/invoker/ClientModel.java
new file mode 100644
index 0000000..52f4bd9
--- /dev/null
+++ b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/invoker/ClientModel.java
@@ -0,0 +1,39 @@
+/*
+ * 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.pojo.client.invoker;
+
+public class ClientModel {
+  private String name;
+  private int code;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public int getCode() {
+    return code;
+  }
+
+  public void setCode(int code) {
+    this.code = code;
+  }
+}
\ No newline at end of file
diff --git a/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/invoker/TestInvokerEndpoint.java b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/invoker/TestInvokerEndpoint.java
new file mode 100644
index 0000000..ca74092
--- /dev/null
+++ b/demo/demo-pojo/pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/invoker/TestInvokerEndpoint.java
@@ -0,0 +1,153 @@
+/*
+ * 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.pojo.client.invoker;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.servicecomb.core.provider.consumer.InvokerUtils;
+import org.apache.servicecomb.demo.CategorizedTestCase;
+import org.apache.servicecomb.demo.TestMgr;
+import org.springframework.stereotype.Component;
+
+@Component
+@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
+public class TestInvokerEndpoint implements CategorizedTestCase {
+  @Override
+  public void testRestTransport() throws Exception {
+    testInvokerUtilsDiffModelRest();
+  }
+
+  @Override
+  public void testHighwayTransport() throws Exception {
+    testInvokerUtilsDiffModelHighway();
+  }
+
+  @Override
+  public void testAllTransport() throws Exception {
+    testInvokerUtilsDiffModel();
+    testInvokerUtilsDiffModelMapArgs();
+  }
+
+  private void testInvokerUtilsDiffModelHighway() throws Exception {
+    Map<String, Object> args = new HashMap<>();
+    ClientModel model = new ClientModel();
+    model.setCode(200);
+    model.setName("hello");
+    args.put("request", model);
+
+    Map result = (Map) InvokerUtils.syncInvoke("pojo", "0+", "highway", "InvokerEndpoint", "model", args);
+    TestMgr.check(model.getCode(), result.get("code"));
+    TestMgr.check(model.getName(), result.get("name"));
+
+    ClientModel modelResult = InvokerUtils
+        .syncInvoke("pojo", "0+", "highway", "InvokerEndpoint", "model", args, ClientModel.class);
+    TestMgr.check(model.getCode(), modelResult.getCode());
+    TestMgr.check(model.getName(), modelResult.getName());
+
+    CountDownLatch countDownLatch = new CountDownLatch(1);
+    InvokerUtils
+        .reactiveInvoke("pojo", "0+", "highway", "InvokerEndpoint", "model", args, ClientModel.class, response -> {
+          ClientModel reactiveResult = response.getResult();
+          TestMgr.check(model.getCode(), reactiveResult.getCode());
+          TestMgr.check(model.getName(), reactiveResult.getName());
+          System.out.println("done");
+          countDownLatch.countDown();
+        });
+    countDownLatch.await();
+  }
+
+  private void testInvokerUtilsDiffModelRest() throws Exception {
+    Map<String, Object> args = new HashMap<>();
+    ClientModel model = new ClientModel();
+    model.setCode(200);
+    model.setName("hello");
+    args.put("request", model);
+
+    Map result = (Map) InvokerUtils.syncInvoke("pojo", "0+", "rest", "InvokerEndpoint", "model", args);
+    TestMgr.check(model.getCode(), result.get("code"));
+    TestMgr.check(model.getName(), result.get("name"));
+
+    ClientModel modelResult = InvokerUtils
+        .syncInvoke("pojo", "0+", "rest", "InvokerEndpoint", "model", args, ClientModel.class);
+    TestMgr.check(model.getCode(), modelResult.getCode());
+    TestMgr.check(model.getName(), modelResult.getName());
+
+    CountDownLatch countDownLatch = new CountDownLatch(1);
+    InvokerUtils.reactiveInvoke("pojo", "0+", "rest", "InvokerEndpoint", "model", args, ClientModel.class, response -> {
+      ClientModel reactiveResult = response.getResult();
+      TestMgr.check(model.getCode(), reactiveResult.getCode());
+      TestMgr.check(model.getName(), reactiveResult.getName());
+      System.out.println("done");
+      countDownLatch.countDown();
+    });
+    countDownLatch.await();
+  }
+
+  private void testInvokerUtilsDiffModel() throws Exception {
+    Map<String, Object> args = new HashMap<>();
+    ClientModel model = new ClientModel();
+    model.setCode(200);
+    model.setName("hello");
+    args.put("request", model);
+
+    Map result = (Map) InvokerUtils.syncInvoke("pojo", "InvokerEndpoint", "model", args);
+    TestMgr.check(model.getCode(), result.get("code"));
+    TestMgr.check(model.getName(), result.get("name"));
+
+    ClientModel modelResult = InvokerUtils.syncInvoke("pojo", "InvokerEndpoint", "model", args, ClientModel.class);
+    TestMgr.check(model.getCode(), modelResult.getCode());
+    TestMgr.check(model.getName(), modelResult.getName());
+
+    CountDownLatch countDownLatch = new CountDownLatch(1);
+    InvokerUtils.reactiveInvoke("pojo", "InvokerEndpoint", "model", args, ClientModel.class, response -> {
+      ClientModel reactiveResult = response.getResult();
+      TestMgr.check(model.getCode(), reactiveResult.getCode());
+      TestMgr.check(model.getName(), reactiveResult.getName());
+      System.out.println("done");
+      countDownLatch.countDown();
+    });
+    countDownLatch.await();
+  }
+
+  private void testInvokerUtilsDiffModelMapArgs() throws Exception {
+    Map<String, Object> args = new HashMap<>();
+    Map model = new HashMap();
+    model.put("code", 20);
+    model.put("name", "hello");
+    args.put("request", model);
+
+    Map result = (Map) InvokerUtils.syncInvoke("pojo", "InvokerEndpoint", "model", args);
+    TestMgr.check(model.get("code"), result.get("code"));
+    TestMgr.check(model.get("name"), result.get("name"));
+
+    ClientModel modelResult = InvokerUtils.syncInvoke("pojo", "InvokerEndpoint", "model", args, ClientModel.class);
+    TestMgr.check(model.get("code"), modelResult.getCode());
+    TestMgr.check(model.get("name"), modelResult.getName());
+
+    CountDownLatch countDownLatch = new CountDownLatch(1);
+    InvokerUtils.reactiveInvoke("pojo", "InvokerEndpoint", "model", args, ClientModel.class, response -> {
+      ClientModel reactiveResult = response.getResult();
+      TestMgr.check(model.get("code"), reactiveResult.getCode());
+      TestMgr.check(model.get("name"), reactiveResult.getName());
+      countDownLatch.countDown();
+    });
+    countDownLatch.await();
+  }
+}
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/invoker/InvokerEndpoint.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/invoker/InvokerEndpoint.java
new file mode 100644
index 0000000..4333bf3
--- /dev/null
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/invoker/InvokerEndpoint.java
@@ -0,0 +1,27 @@
+/*
+ * 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.pojo.server.invoker;
+
+import org.apache.servicecomb.provider.pojo.RpcSchema;
+
+@RpcSchema(schemaId = "InvokerEndpoint")
+public class InvokerEndpoint {
+  public ServerModel model(ServerModel request) {
+    return request;
+  }
+}
diff --git a/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/invoker/ServerModel.java b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/invoker/ServerModel.java
new file mode 100644
index 0000000..3320f27
--- /dev/null
+++ b/demo/demo-pojo/pojo-server/src/main/java/org/apache/servicecomb/demo/pojo/server/invoker/ServerModel.java
@@ -0,0 +1,39 @@
+/*
+ * 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.pojo.server.invoker;
+
+public class ServerModel {
+  private String name;
+  private int code;
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public int getCode() {
+    return code;
+  }
+
+  public void setCode(int code) {
+    this.code = code;
+  }
+}
diff --git a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClientTest.java b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClientTest.java
index 701aa9a..a67bfa6 100644
--- a/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClientTest.java
+++ b/demo/demo-spring-boot-transport/demo-spring-boot-pojo-client/src/main/java/org/apache/servicecomb/demo/pojo/client/PojoClientTest.java
@@ -91,6 +91,7 @@ public class PojoClientTest {
         result);
   }
 
+  @SuppressWarnings({"deprecation"})
   private static void testCommonInvoke(String transport) {
     Map<String, Object> arguments = new HashMap<>();
     arguments.put("index", 2);
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestWeakSpringmvc.java b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestWeakSpringmvc.java
index a2f9817..6f92d92 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestWeakSpringmvc.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestWeakSpringmvc.java
@@ -171,6 +171,7 @@ public class TestWeakSpringmvc implements CategorizedTestCase {
     TestMgr.check("hello", nameListResult.get(0).get(0));
   }
 
+  @SuppressWarnings({"deprecation"})
   private void testDiffName() {
     TestMgr.check(7, diffNames.differentName(2, 3));
     TestMgr.check(8, diffNames2.differentName(2, 3));