diff --git a/pom.xml b/pom.xml index 63c098e4aa..fa526126df 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 pom Trpc Parent Project ${project.version} trpc @@ -89,12 +89,12 @@ 3.0.1 3.0.1 3.1.2 - 1.8 - 1.8 + 17 + 17 3.7.0 3.1.0 false - 2.22.0 + 3.1.2 3.0.1 0.7.0 3.1.0 @@ -122,29 +122,48 @@ - org.powermock - powermock-module-junit4 + org.junit.jupiter + junit-jupiter-api + 5.9.3 test - org.powermock - powermock-api-mockito + org.junit.jupiter + junit-jupiter-engine + 5.9.3 test + - org.powermock - powermock-api-support - test - - - org.powermock - powermock-module-junit4-rule + junit + junit + 4.13.2 test + + + + + + + + + + + + + + + + + + + + org.jacoco org.jacoco.agent - 0.8.6 + 0.8.11 runtime test @@ -177,6 +196,10 @@ maven-surefire-plugin ${maven.surefire.version} + + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + ${maven.ignore.testfailure} false @@ -249,7 +272,7 @@ org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.8 false diff --git a/trpc-admin/pom.xml b/trpc-admin/pom.xml index a08be1802f..853f6379ca 100644 --- a/trpc-admin/pom.xml +++ b/trpc-admin/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-admin diff --git a/trpc-admin/trpc-admin-default/pom.xml b/trpc-admin/trpc-admin-default/pom.xml index 6d0bba634f..605bfb31ed 100644 --- a/trpc-admin/trpc-admin-default/pom.xml +++ b/trpc-admin/trpc-admin-default/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-admin - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-bootstrap/pom.xml b/trpc-bootstrap/pom.xml index c3ab22003b..d64292384c 100644 --- a/trpc-bootstrap/pom.xml +++ b/trpc-bootstrap/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-bootstrap diff --git a/trpc-bootstrap/trpc-server/pom.xml b/trpc-bootstrap/trpc-server/pom.xml index 2c89be6e28..1d5d769209 100644 --- a/trpc-bootstrap/trpc-server/pom.xml +++ b/trpc-bootstrap/trpc-server/pom.xml @@ -5,7 +5,7 @@ com.tencent.trpc trpc-bootstrap - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-code-generator/pom.xml b/trpc-code-generator/pom.xml index 5b9d785701..fe85c01c6b 100644 --- a/trpc-code-generator/pom.xml +++ b/trpc-code-generator/pom.xml @@ -7,7 +7,7 @@ trpc-parent com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 trpc-code-generator diff --git a/trpc-configcenter/pom.xml b/trpc-configcenter/pom.xml index c5f57de9d7..a77b066feb 100644 --- a/trpc-configcenter/pom.xml +++ b/trpc-configcenter/pom.xml @@ -5,7 +5,7 @@ trpc-parent com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-configcenter/trpc-configcenter-nacos/pom.xml b/trpc-configcenter/trpc-configcenter-nacos/pom.xml index bc7404e8b6..c8a354ee6d 100644 --- a/trpc-configcenter/trpc-configcenter-nacos/pom.xml +++ b/trpc-configcenter/trpc-configcenter-nacos/pom.xml @@ -6,7 +6,7 @@ com.tencent.trpc trpc-configcenter - 1.4.0-SNAPSHOT + 2.0.1 jar ${project.artifactId} diff --git a/trpc-configcenter/trpc-configcenter-open-polaris/pom.xml b/trpc-configcenter/trpc-configcenter-open-polaris/pom.xml index 2bebf3e0ff..f8e6bfbafb 100644 --- a/trpc-configcenter/trpc-configcenter-open-polaris/pom.xml +++ b/trpc-configcenter/trpc-configcenter-open-polaris/pom.xml @@ -6,7 +6,7 @@ com.tencent.trpc trpc-configcenter - 1.4.0-SNAPSHOT + 2.0.1 jar ${project.artifactId} diff --git a/trpc-container/pom.xml b/trpc-container/pom.xml index 885244e4e1..4e3eddae0d 100644 --- a/trpc-container/pom.xml +++ b/trpc-container/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-container diff --git a/trpc-container/trpc-container-default/pom.xml b/trpc-container/trpc-container-default/pom.xml index aaa28f2f26..8c82e4d949 100644 --- a/trpc-container/trpc-container-default/pom.xml +++ b/trpc-container/trpc-container-default/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-container - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-core/pom.xml b/trpc-core/pom.xml index d8a5b4eec8..48bc7c6026 100644 --- a/trpc-core/pom.xml +++ b/trpc-core/pom.xml @@ -8,7 +8,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-core/src/main/java/com/tencent/trpc/core/common/Version.java b/trpc-core/src/main/java/com/tencent/trpc/core/common/Version.java index 0c6e1da626..7e645f1978 100644 --- a/trpc-core/src/main/java/com/tencent/trpc/core/common/Version.java +++ b/trpc-core/src/main/java/com/tencent/trpc/core/common/Version.java @@ -31,13 +31,13 @@ public class Version { * VERSION: Do not modify the line number of this line. If you want to modify it, be sure to change deploy.sh at * the same time. */ - public static final String VERSION = "v1.4.0"; + public static final String VERSION = "v2.0.1"; public static final String SNAPSHOT_VERSION = VERSION + VERSION_SUFFIX; /** * IS_FORMAL_VERSION: Do not modify the line number of this line. If you want to modify it, be sure to change * deploy.sh atthe same time. */ - public static final boolean IS_FORMAL_VERSION = false; + public static final boolean IS_FORMAL_VERSION = true; /** * Version returns the version number of the trpc framework. diff --git a/trpc-core/src/main/java/com/tencent/trpc/core/utils/JsonUtils.java b/trpc-core/src/main/java/com/tencent/trpc/core/utils/JsonUtils.java index e53e99d6d3..cab1399998 100644 --- a/trpc-core/src/main/java/com/tencent/trpc/core/utils/JsonUtils.java +++ b/trpc-core/src/main/java/com/tencent/trpc/core/utils/JsonUtils.java @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making tRPC available. * - * Copyright (C) 2023 THL A29 Limited, a Tencent company. + * Copyright (C) 2023 THL A29 Limited, a Tencent company. * All rights reserved. * * If you have downloaded a copy of the tRPC source code from Tencent, @@ -23,6 +23,7 @@ import com.tencent.trpc.core.logger.LoggerFactory; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Type; /** * JSON utility. @@ -71,6 +72,26 @@ public static T fromInputStream(InputStream is, Class clz) { } } + /** + * json to Type + * + * @param is JSON input stream + * @param type the class of the Type to deserialize + * @param the type of the deserialized object + * @return the deserialized object + */ + public static T fromInputStream(InputStream is, Type type) { + try { + return objectMapper + .readValue(is, objectMapper.getTypeFactory().constructType(type)); + } catch (Exception e) { + logger.error("object mapper readValue error:", e); + throw TRpcException.newException(ErrorCode.JSON_DESERIALIZATION_ERR, 0, + "object mapper readValue to Type error, jsonStream:%s, type:%s", + is, type.getTypeName()); + } + } + /** * JSON to Object. * @@ -126,6 +147,26 @@ public static T fromJson(String json, TypeReference typeReference) { } } + /** + * json to Type + * + * @param json JSON string + * @param type the type reference of the object to deserialize + * @param the type of the deserialized object + * @return the deserialized object + */ + public static T fromJson(String json, Type type) { + try { + return objectMapper + .readValue(json, objectMapper.getTypeFactory().constructType(type)); + } catch (Exception e) { + logger.error("object mapper readValue error:", e); + throw TRpcException.newException(ErrorCode.JSON_DESERIALIZATION_ERR, 0, + "object mapper readValue to Type error, json:%s, type:%s", json, + type.getTypeName()); + } + } + /** * Byte arrays to Object. * diff --git a/trpc-demo/pom.xml b/trpc-demo/pom.xml index c2367e83f3..4a9f335cb5 100644 --- a/trpc-demo/pom.xml +++ b/trpc-demo/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-demo diff --git a/trpc-demo/trpc-java-demo/pom.xml b/trpc-demo/trpc-java-demo/pom.xml index 5a67f41fef..ffed39492f 100644 --- a/trpc-demo/trpc-java-demo/pom.xml +++ b/trpc-demo/trpc-java-demo/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-demo - 1.4.0-SNAPSHOT + 2.0.1 trpc-demo Demo project for Spring Boot @@ -49,7 +49,7 @@ org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.8 true diff --git a/trpc-demo/trpc-spring-demo/pom.xml b/trpc-demo/trpc-spring-demo/pom.xml index 5af49393a0..080581a430 100644 --- a/trpc-demo/trpc-spring-demo/pom.xml +++ b/trpc-demo/trpc-spring-demo/pom.xml @@ -9,13 +9,14 @@ trpc-spring-server-demo trpc-spring-client-demo + trpc-spring-demo-api pom com.tencent.trpc trpc-demo - 1.4.0-SNAPSHOT + 2.0.1 trpc-spring-demo Maven Webapp diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/pom.xml b/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/pom.xml index 29ea252612..17f248df95 100644 --- a/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/pom.xml +++ b/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/pom.xml @@ -5,7 +5,7 @@ trpc-spring-demo com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 @@ -17,6 +17,11 @@ com.tencent.trpc trpc-proto-http + + com.tencent.trpc + trpc-spring-demo-api + ${parent.version} + diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/java/com/tencent/trpc/spring/demo/ClientApplication.java b/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/java/com/tencent/trpc/spring/demo/ClientApplication.java index e1683cf71b..4af309c36b 100644 --- a/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/java/com/tencent/trpc/spring/demo/ClientApplication.java +++ b/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/java/com/tencent/trpc/spring/demo/ClientApplication.java @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making tRPC available. * - * Copyright (C) 2023 THL A29 Limited, a Tencent company. + * Copyright (C) 2023 THL A29 Limited, a Tencent company. * All rights reserved. * * If you have downloaded a copy of the tRPC source code from Tencent, @@ -12,6 +12,8 @@ package com.tencent.trpc.spring.demo; import com.google.protobuf.Message; +import com.tencent.trpc.GreeterService3API; +import com.tencent.trpc.GreeterService3API.RequestParameterizedBean; import com.tencent.trpc.core.rpc.RpcClientContext; import com.tencent.trpc.core.rpc.RpcContext; import com.tencent.trpc.demo.proto.GreeterService2AsyncAPI; @@ -39,20 +41,26 @@ public static void main(String[] args) throws Exception { GreeterService2AsyncAPI service2 = context.getBean(ProxyService.SERVICE_NAME2, GreeterService2AsyncAPI.class); + GreeterService3API service3 = context.getBean(ProxyService.SERVICE_NAME3, + GreeterService3API.class); + RpcContext ctx = new RpcClientContext(); HelloRequestProtocol.HelloRequest request = HelloRequestProtocol.HelloRequest.newBuilder() .setMessage("tRPC-Java") .build(); + RequestParameterizedBean parameterizedBean = RequestParameterizedBean.of("message", + "hello parameterizedBean"); int times = 5; for (int i = 0; i < times; i++) { System.out.println("service1>>>>" + syncGetMessage(service1.sayHello(ctx, request))); System.out.println("service2>>>>" + syncGetMessage(service2.sayHi(ctx, request))); - System.out.println("demo service1>>>>" + - syncGetMessage(demoService.getGreeterService().sayHello(ctx, request))); - System.out.println("demo service2>>>>" + - syncGetMessage(demoService.getGreeterService2().sayHi(ctx, request))); + System.out.println("service3>>>>" + service3.sayHelloParameterized(ctx, parameterizedBean)); + System.out.println("demo service1>>>>" + + syncGetMessage(demoService.getGreeterService().sayHello(ctx, request))); + System.out.println("demo service2>>>>" + + syncGetMessage(demoService.getGreeterService2().sayHi(ctx, request))); TimeUnit.SECONDS.sleep(1); } diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/java/com/tencent/trpc/spring/demo/server/ProxyService.java b/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/java/com/tencent/trpc/spring/demo/server/ProxyService.java index cea698e058..1b73dbb67d 100644 --- a/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/java/com/tencent/trpc/spring/demo/server/ProxyService.java +++ b/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/java/com/tencent/trpc/spring/demo/server/ProxyService.java @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making tRPC available. * - * Copyright (C) 2023 THL A29 Limited, a Tencent company. + * Copyright (C) 2023 THL A29 Limited, a Tencent company. * All rights reserved. * * If you have downloaded a copy of the tRPC source code from Tencent, @@ -11,6 +11,7 @@ package com.tencent.trpc.spring.demo.server; +import com.tencent.trpc.GreeterService3API; import com.tencent.trpc.demo.proto.GreeterService2AsyncAPI; import com.tencent.trpc.demo.proto.GreeterServiceAsyncAPI; import com.tencent.trpc.spring.annotation.TRpcClient; @@ -21,6 +22,7 @@ public class ProxyService { public static final String SERVICE_NAME1 = "trpc.TestApp.TestServer.Greeter1"; public static final String SERVICE_NAME2 = "trpc.TestApp.TestServer.Greeter2"; + public static final String SERVICE_NAME3 = "trpc.TestApp.TestServer.Greeter3"; @TRpcClient(id = SERVICE_NAME1) private GreeterServiceAsyncAPI greeterService; @@ -28,6 +30,9 @@ public class ProxyService { @TRpcClient(id = SERVICE_NAME2) private GreeterService2AsyncAPI greeterService2; + @TRpcClient(id = SERVICE_NAME3) + private GreeterService3API greeterService3; + public GreeterServiceAsyncAPI getGreeterService() { return greeterService; } @@ -36,4 +41,8 @@ public GreeterService2AsyncAPI getGreeterService2() { return greeterService2; } + public GreeterService3API getGreeterService3() { + return greeterService3; + } + } diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/resources/application.yml b/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/resources/application.yml index 48ad1ec684..e9b88cad30 100644 --- a/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/resources/application.yml +++ b/trpc-demo/trpc-spring-demo/trpc-spring-client-demo/src/main/resources/application.yml @@ -14,3 +14,8 @@ trpc: interface: com.tencent.trpc.demo.proto.GreeterService2AsyncAPI # Service interface protocol: http # Protocol type, default is trpc basePath: /rest # The base path of the client service url address + - name: trpc.TestApp.TestServer.Greeter3 # Service name + naming_url: ip://127.0.0.1:12322 # Router address + interface: com.tencent.trpc.GreeterService3API # Service interface + protocol: http # Protocol type, default is trpc + basePath: /rest # The base path of the client service url address diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-demo-api/pom.xml b/trpc-demo/trpc-spring-demo/trpc-spring-demo-api/pom.xml new file mode 100644 index 0000000000..6b9351f2e6 --- /dev/null +++ b/trpc-demo/trpc-spring-demo/trpc-spring-demo-api/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.tencent.trpc + trpc-spring-demo + 2.0.1 + + + trpc-spring-demo-api + jar + ${project.artifactId} + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-demo-api/src/main/java/com/tencent/trpc/GreeterService3API.java b/trpc-demo/trpc-spring-demo/trpc-spring-demo-api/src/main/java/com/tencent/trpc/GreeterService3API.java new file mode 100644 index 0000000000..18f724c95e --- /dev/null +++ b/trpc-demo/trpc-spring-demo/trpc-spring-demo-api/src/main/java/com/tencent/trpc/GreeterService3API.java @@ -0,0 +1,42 @@ +package com.tencent.trpc; + +import com.tencent.trpc.core.rpc.RpcContext; +import com.tencent.trpc.core.rpc.anno.TRpcMethod; +import com.tencent.trpc.core.rpc.anno.TRpcService; +import java.util.Map; + +@TRpcService(name = "trpc.TestApp.TestServer.GreeterService3") +public interface GreeterService3API { + + @TRpcMethod(name = "sayHelloParameterized") + Map sayHelloParameterized(RpcContext context, RequestParameterizedBean request); + + class RequestParameterizedBean { + + String message; + T data; + + public static RequestParameterizedBean of(String message, T data) { + RequestParameterizedBean bean = new RequestParameterizedBean<>(); + bean.setMessage(message); + bean.setData(data); + return bean; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + } +} diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/pom.xml b/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/pom.xml index d9c241305c..c0d9de9972 100644 --- a/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/pom.xml +++ b/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/pom.xml @@ -5,7 +5,7 @@ trpc-spring-demo com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 @@ -17,6 +17,11 @@ com.tencent.trpc trpc-springmvc + + com.tencent.trpc + trpc-spring-demo-api + ${parent.version} + diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/src/main/java/com/tencent/trpc/spring/demo/server/impl/GreeterServiceImpl3.java b/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/src/main/java/com/tencent/trpc/spring/demo/server/impl/GreeterServiceImpl3.java new file mode 100644 index 0000000000..7b49972d65 --- /dev/null +++ b/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/src/main/java/com/tencent/trpc/spring/demo/server/impl/GreeterServiceImpl3.java @@ -0,0 +1,22 @@ +package com.tencent.trpc.spring.demo.server.impl; + +import com.tencent.trpc.GreeterService3API; +import com.tencent.trpc.core.logger.Logger; +import com.tencent.trpc.core.logger.LoggerFactory; +import com.tencent.trpc.core.rpc.RpcContext; +import java.util.Collections; +import java.util.Map; +import org.springframework.stereotype.Service; + +@Service +public class GreeterServiceImpl3 implements GreeterService3API { + + private static final Logger logger = LoggerFactory.getLogger(GreeterServiceImpl3.class); + + @Override + public Map sayHelloParameterized(RpcContext context, RequestParameterizedBean request) { + logger.info("got hello json request, request is '{}'", request); + + return Collections.singletonMap("message", "Hi:" + request.getData()); + } +} diff --git a/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/src/main/resources/application.yml b/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/src/main/resources/application.yml index ad8ae23d9f..00cb0935b4 100644 --- a/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/src/main/resources/application.yml +++ b/trpc-demo/trpc-spring-demo/trpc-spring-server-demo/src/main/resources/application.yml @@ -16,8 +16,9 @@ trpc: - name: trpc.TestApp.TestServer.Greeter2 # Service name impls: # Service implement classes - com.tencent.trpc.spring.demo.server.impl.GreeterServiceImpl2 + - com.tencent.trpc.spring.demo.server.impl.GreeterServiceImpl3 ip: 127.0.0.1 # Listen ip port: 12322 # Listen port protocol: rest # Means using trpc-springmvc mode, service exported as spring mvc controller basePath: /rest # The url address is the base_path plus the service name annotated with @TRpcService, and the - # '.' in the service name are all replaced with '/'. Default is '/'. \ No newline at end of file + # '.' in the service name are all replaced with '/'. Default is '/'. \ No newline at end of file diff --git a/trpc-dependencies/pom.xml b/trpc-dependencies/pom.xml index 6ac8747b2d..eeda42ea7a 100644 --- a/trpc-dependencies/pom.xml +++ b/trpc-dependencies/pom.xml @@ -5,7 +5,7 @@ trpc-parent com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-dependencies/trpc-bom/pom.xml b/trpc-dependencies/trpc-bom/pom.xml index e708ef2717..a74cd15be3 100644 --- a/trpc-dependencies/trpc-bom/pom.xml +++ b/trpc-dependencies/trpc-bom/pom.xml @@ -6,7 +6,7 @@ com.tencent.trpc trpc-bom - 1.4.0-SNAPSHOT + 2.0.1 pom trpc-bom trpc diff --git a/trpc-dependencies/trpc-dependencies-bom/pom.xml b/trpc-dependencies/trpc-dependencies-bom/pom.xml index 4317974569..8a30e2cf01 100644 --- a/trpc-dependencies/trpc-dependencies-bom/pom.xml +++ b/trpc-dependencies/trpc-dependencies-bom/pom.xml @@ -6,7 +6,7 @@ com.tencent.trpc trpc-dependencies-bom - 1.4.0-SNAPSHOT + 2.0.1 pom trpc-dependencies-bom trpc @@ -60,7 +60,7 @@ 1.1.0 - 3.12.1 + 3.24.2 2.1.0 1.14.9 2.9.3 @@ -75,7 +75,7 @@ 1.10.0 1.9.4 0.2.12 - 5.0.0 + 5.5.0 1.4.5 3.4.2 2.10.0 @@ -83,26 +83,28 @@ 2.8.9 32.1.3-jre 4.5.14 + 5.4.1 4.4.15 5.2.1 5.8.28 2.15.0-rc2 + 6.0.0 + 2.1.1 + 1.2.1 + 3.0.2 + 2.3.2 2.1.1 2.0.1.Final 8.1.13.v20181017 - 9.4.55.v20240627 + 11.0.25 2.7 2.4.14 - 4.13.2 - 1.3.5 - 1.2.1 - 3.0.2 - 2.3.2 + 5.10.0 3.28.0-GA 3.1.0 3.0.2 1.2.13 - 2.17.1 + 2.24.3 1.3.3 3.1.0 3.0.0 @@ -111,10 +113,11 @@ 3.3.0 1.4.1 3.0.2 - 1.10.19 + 5.5.0 + 5.2.0 1.4.2 2.2.1 - 2.4 + 3.3 4.10.0 0.33.0 12.2 @@ -124,21 +127,22 @@ 1.26.0 3.4.0 1.15.5 - 1.7.4 + 2.0.9 3.25.5 0.4.1 0.6.13 0.7.9 0.9.12 5.0.6.Final + 1.8.6 1.8.6 1.7.36 2.0 1.1.10.4 - 5.3.27 - 2.7.12 - 3.1.5 + 6.2.7 + 3.5.0 + 4.3.0 2.12.4 3.8.4 @@ -537,6 +541,11 @@ httpclient ${httpclient.version} + + org.apache.httpcomponents.core5 + httpcore5 + ${httpcore5.version} + org.apache.httpcomponents.core5 httpcore5-h2 @@ -545,7 +554,7 @@ org.apache.httpcomponents.client5 httpclient5 - ${httpcore5.version} + ${httpclient5.version} curator-recipes @@ -680,6 +689,12 @@ spring-boot-autoconfigure ${springboot.version} + + org.springframework.boot + spring-boot-properties-migrator + ${springboot.version} + runtime + org.springframework.boot spring-boot-configuration-processor @@ -745,10 +760,16 @@ - junit - junit + org.junit.jupiter + junit-jupiter-api + ${junit.version} test + + + org.junit.jupiter + junit-jupiter-engine ${junit.version} + test assertj-core @@ -775,46 +796,16 @@ test - powermock-module-junit4 - org.powermock - test - ${powermock.version} - - - org.powermock - powermock-api-mockito - ${powermock.version} + org.mockito + mockito-junit-jupiter + ${mockito_core.version} test - - - hamcrest-core - org.hamcrest - - - org.powermock - powermock-api-support - ${powermock.version} - test - - - powermock-core - org.powermock - - - - - org.powermock - powermock-module-junit4-rule - ${powermock.version} + org.mockito + mockito-inline + ${mockito-inline.version} test - - - mockito-core - org.mockito - - org.springframework.boot @@ -960,6 +951,11 @@ validation-api ${javax.validation.version} + + jakarta.servlet + jakarta.servlet-api + ${jakarta.servlet.version} + diff --git a/trpc-dependencies/trpc-mini/pom.xml b/trpc-dependencies/trpc-mini/pom.xml index e9bcf9bd62..bdc6865c8e 100644 --- a/trpc-dependencies/trpc-mini/pom.xml +++ b/trpc-dependencies/trpc-mini/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-dependencies - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-dependencies/trpc-standard/pom.xml b/trpc-dependencies/trpc-standard/pom.xml index b71d71258e..11a0f016eb 100644 --- a/trpc-dependencies/trpc-standard/pom.xml +++ b/trpc-dependencies/trpc-standard/pom.xml @@ -5,7 +5,7 @@ trpc-dependencies com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-limiter/pom.xml b/trpc-limiter/pom.xml index 28f4d648b9..b7acb6c385 100644 --- a/trpc-limiter/pom.xml +++ b/trpc-limiter/pom.xml @@ -8,7 +8,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-limiter diff --git a/trpc-limiter/trpc-limiter-sentinel/pom.xml b/trpc-limiter/trpc-limiter-sentinel/pom.xml index d050bb1899..af1992b1e8 100644 --- a/trpc-limiter/trpc-limiter-sentinel/pom.xml +++ b/trpc-limiter/trpc-limiter-sentinel/pom.xml @@ -10,7 +10,7 @@ com.tencent.trpc trpc-limiter - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-logger/pom.xml b/trpc-logger/pom.xml index 3f1d118c37..f0a8bac3b1 100644 --- a/trpc-logger/pom.xml +++ b/trpc-logger/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-logger diff --git a/trpc-logger/trpc-logger-admin/pom.xml b/trpc-logger/trpc-logger-admin/pom.xml index 3a78e7c8a3..02ab6466d4 100644 --- a/trpc-logger/trpc-logger-admin/pom.xml +++ b/trpc-logger/trpc-logger-admin/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-logger - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-maven-plugin/pom.xml b/trpc-maven-plugin/pom.xml index 115b0dd023..34e31ede04 100644 --- a/trpc-maven-plugin/pom.xml +++ b/trpc-maven-plugin/pom.xml @@ -7,7 +7,7 @@ trpc-parent com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 trpc-maven-plugin diff --git a/trpc-opentelemetry/pom.xml b/trpc-opentelemetry/pom.xml index db6eebfe55..e1e9d5a257 100644 --- a/trpc-opentelemetry/pom.xml +++ b/trpc-opentelemetry/pom.xml @@ -6,7 +6,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-opentelemetry diff --git a/trpc-proto/pom.xml b/trpc-proto/pom.xml index cb957841d9..0081cf651e 100644 --- a/trpc-proto/pom.xml +++ b/trpc-proto/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-proto diff --git a/trpc-proto/trpc-proto-http/pom.xml b/trpc-proto/trpc-proto-http/pom.xml index 81f309d22d..94be030458 100644 --- a/trpc-proto/trpc-proto-http/pom.xml +++ b/trpc-proto/trpc-proto-http/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-proto - 1.4.0-SNAPSHOT + 2.0.1 jar @@ -60,5 +60,9 @@ commons-beanutils commons-beanutils + + jakarta.servlet + jakarta.servlet-api + diff --git a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/client/AbstractConsumerInvoker.java b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/client/AbstractConsumerInvoker.java index 18b4ce28ae..e1e1b7c7c2 100644 --- a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/client/AbstractConsumerInvoker.java +++ b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/client/AbstractConsumerInvoker.java @@ -201,9 +201,10 @@ protected String encodeToJson(Request request) { if (paramsTypes.length <= 1) { return null; } - Class reqType = (Class) paramsTypes[1]; - - if (Message.class.isAssignableFrom(reqType)) { + Type reqType = paramsTypes[1]; + // The protobuf Message type uses ProtoJsonConverter for JSON data conversion, + // the other types use JsonUtils, supporting request parameters with generic type parameters + if (reqType instanceof Class && Message.class.isAssignableFrom((Class) reqType)) { Map jsonData = ProtoJsonConverter.messageToMap((Message) param); return JsonUtils.toJson(jsonData); } else { diff --git a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/ErrorResponse.java b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/ErrorResponse.java index 0eca7e9482..b1f494ad1d 100644 --- a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/ErrorResponse.java +++ b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/ErrorResponse.java @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; import java.util.Optional; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.lang3.StringUtils; /** diff --git a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/HttpCodec.java b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/HttpCodec.java index 77f3a258a5..ce145fabb3 100644 --- a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/HttpCodec.java +++ b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/HttpCodec.java @@ -17,16 +17,18 @@ import com.tencent.trpc.core.serialization.spi.Serialization; import com.tencent.trpc.core.serialization.support.JSONSerialization; import com.tencent.trpc.core.serialization.support.PBSerialization; +import com.tencent.trpc.core.utils.JsonUtils; import com.tencent.trpc.core.utils.ProtoJsonConverter; import com.tencent.trpc.proto.http.util.StreamUtils; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.apache.commons.beanutils.BeanUtils; import org.apache.http.HttpHeaders; @@ -181,6 +183,33 @@ public Object convertToJavaBean(HttpServletRequest request, Class msgType) th return bean; } + /** + * Convert HTTP request body to Parameterized Types POJO + * + * @param request HttpServletRequest + * @param type the type of decoded param + * @return decoded param + * @throws Exception if param parsing failed + */ + public Object convertToParameterizedBean(HttpServletRequest request, Type type) throws Exception { + Map params = new HashMap<>(); + if (HttpConstants.HTTP_METHOD_GET.equalsIgnoreCase(request.getMethod())) { + Enumeration parameterNames = request.getParameterNames(); + while (parameterNames.hasMoreElements()) { + String param = parameterNames.nextElement(); + params.put(param, request.getParameter(param)); + } + return JsonUtils.fromJson(JsonUtils.toJson(params), type); + } + String contentType = request.getContentType().toLowerCase(); + if (contentType.startsWith(HttpConstants.CONTENT_TYPE_JSON)) { + return JsonUtils.fromInputStream(request.getInputStream(), type); + } else { + // unsupported content-type + throw new IllegalArgumentException("unsupported content-type " + contentType); + } + } + /** * Serialize the return result. Currently, all results are converted to JSON. * diff --git a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/TrpcServletRequestWrapper.java b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/TrpcServletRequestWrapper.java index eedf3d1260..49a63b5f23 100644 --- a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/TrpcServletRequestWrapper.java +++ b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/TrpcServletRequestWrapper.java @@ -13,8 +13,8 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; /** * The HTTP requests encapsulated by TRPC cannot be serialized. diff --git a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/TrpcServletResponseWrapper.java b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/TrpcServletResponseWrapper.java index 5d1735c64f..623676b073 100644 --- a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/TrpcServletResponseWrapper.java +++ b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/common/TrpcServletResponseWrapper.java @@ -13,8 +13,8 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpServletResponseWrapper; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponseWrapper; /** * The HTTP responses encapsulated by TRPC cannot be serialized. diff --git a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutor.java b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutor.java index 7708bc2360..e12345b9ca 100644 --- a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutor.java +++ b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutor.java @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making tRPC available. * - * Copyright (C) 2023 THL A29 Limited, a Tencent company. + * Copyright (C) 2023 THL A29 Limited, a Tencent company. * All rights reserved. * * If you have downloaded a copy of the tRPC source code from Tencent, @@ -19,11 +19,11 @@ import com.tencent.trpc.core.exception.TRpcException; import com.tencent.trpc.core.logger.Logger; import com.tencent.trpc.core.logger.LoggerFactory; -import com.tencent.trpc.core.rpc.RpcContext; import com.tencent.trpc.core.rpc.CallInfo; import com.tencent.trpc.core.rpc.ProviderInvoker; import com.tencent.trpc.core.rpc.RequestMeta; import com.tencent.trpc.core.rpc.Response; +import com.tencent.trpc.core.rpc.RpcContext; import com.tencent.trpc.core.rpc.RpcInvocation; import com.tencent.trpc.core.rpc.RpcServerContext; import com.tencent.trpc.core.rpc.common.RpcMethodInfo; @@ -38,6 +38,9 @@ import com.tencent.trpc.proto.http.common.RpcServerContextWithHttp; import com.tencent.trpc.proto.http.common.TrpcServletRequestWrapper; import com.tencent.trpc.proto.http.common.TrpcServletResponseWrapper; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.net.InetSocketAddress; import java.nio.charset.StandardCharsets; @@ -46,8 +49,6 @@ import java.util.concurrent.CompletionStage; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; @@ -99,7 +100,7 @@ protected void execute(HttpServletRequest request, HttpServletResponse response, * Get the mapped internal method. * * @param object the key to query the mapped internal method, maby {@link HttpServletRequest} or directly - * {@link RpcMethodInfoAndInvoker}. + * {@link RpcMethodInfoAndInvoker}. * @return the mapped internal method */ protected abstract RpcMethodInfoAndInvoker getRpcMethodInfoAndInvoker(Object object); @@ -301,16 +302,23 @@ private Object[] parseRpcParams(HttpServletRequest request, RpcMethodInfo method throw new UnsupportedOperationException("only support trpc service signature"); } - Class reqType = (Class) paramsTypes[1]; + Type type = paramsTypes[1]; Object[] arguments = new Object[1]; - if (Message.class.isAssignableFrom(reqType)) { - arguments[0] = httpCodec.convertToPBParam(request, (Class) reqType); - } else if (Map.class.isAssignableFrom(reqType)) { - arguments[0] = httpCodec.convertToJsonParam(request); + if (type instanceof ParameterizedType) { + // ParameterizedType params + arguments[0] = httpCodec.convertToParameterizedBean(request, type); } else { - // Directly convert to POJO. - arguments[0] = httpCodec.convertToJavaBean(request, reqType); + Class reqType = (Class) type; + if (Message.class.isAssignableFrom(reqType)) { + arguments[0] = httpCodec.convertToPBParam(request, (Class) reqType); + } else if (Map.class.isAssignableFrom(reqType)) { + arguments[0] = httpCodec.convertToJsonParam(request); + } else { + // Directly convert to POJO + arguments[0] = httpCodec.convertToJavaBean(request, reqType); + } } + return arguments; } diff --git a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/DefaultHttpExecutor.java b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/DefaultHttpExecutor.java index 471a83177a..95cf2a786a 100644 --- a/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/DefaultHttpExecutor.java +++ b/trpc-proto/trpc-proto-http/src/main/java/com/tencent/trpc/proto/http/server/DefaultHttpExecutor.java @@ -25,8 +25,8 @@ import com.tencent.trpc.proto.http.common.HttpConstants; import com.tencent.trpc.transport.http.HttpExecutor; import java.util.Optional; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; diff --git a/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/HttpRpcClientTest.java b/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/HttpRpcClientTest.java index 6414c2cfe0..4380572c92 100644 --- a/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/HttpRpcClientTest.java +++ b/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/HttpRpcClientTest.java @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making tRPC available. * - * Copyright (C) 2023 THL A29 Limited, a Tencent company. + * Copyright (C) 2023 THL A29 Limited, a Tencent company. * All rights reserved. * * If you have downloaded a copy of the tRPC source code from Tencent, @@ -43,11 +43,14 @@ import tests.service.GreeterJavaBeanService.RequestBean; import tests.service.GreeterJavaBeanService.ResponseBean; import tests.service.GreeterJsonService; +import tests.service.GreeterParameterizedService; +import tests.service.GreeterParameterizedService.RequestParameterizedBean; import tests.service.GreeterService; import tests.service.HelloRequestProtocol.HelloRequest; import tests.service.HelloRequestProtocol.HelloResponse; import tests.service.impl1.GreeterJavaBeanServiceImpl; import tests.service.impl1.GreeterJsonServiceImpl1; +import tests.service.impl1.GreeterParameterizedServiceImpl; import tests.service.impl1.GreeterServiceImpl1; public class HttpRpcClientTest { @@ -58,15 +61,12 @@ public class HttpRpcClientTest { private static final String CST_BASE_PATH2 = "/test-base-path"; private static final String TEST_MESSAGE = "hello"; private static final String TEST_INNER_MESSAGE = "tRPC-Java!"; - - private static ServerConfig serverConfig; - private static final String CONTAINER_KEY = "test-container"; private static final String FULL_SET_KEY = "test-fullset"; - private static final Integer REQUEST_TIMEOUT = 1000; private static final Integer MAX_CONNECTIONS = 20480; private static final Integer CONNECTION_REQUEST_TIMEOUT_VALUE = 900; + private static ServerConfig serverConfig; @BeforeClass public static void startHttpServer() { @@ -91,29 +91,34 @@ public static void startHttpServer() { javaBeanService.setServiceInterface(GreeterJavaBeanService.class); javaBeanService.setRef(new GreeterJavaBeanServiceImpl()); + ProviderConfig parameterizedService = new ProviderConfig<>(); + parameterizedService.setServiceInterface(GreeterParameterizedService.class); + parameterizedService.setRef(new GreeterParameterizedServiceImpl()); + HashMap providers = new HashMap<>(); ServiceConfig serviceConfig1 = getServiceConfig(gspc, "test.server1", NetUtils.LOCAL_HOST, 18088, HTTP_SCHEME, "jetty"); providers.put(serviceConfig1.getName(), serviceConfig1); - ServiceConfig serviceConfig2 = getServiceConfig(gjspc, "test.server2", NetUtils.LOCAL_HOST, 18088, HTTP_SCHEME, "jetty"); providers.put(serviceConfig2.getName(), serviceConfig2); - ServiceConfig serviceConfig3 = getServiceConfig(gspc, "test.server3", NetUtils.LOCAL_HOST, 18089, HTTP_SCHEME, "jetty", CST_BASE_PATH1); providers.put(serviceConfig3.getName(), serviceConfig3); - ServiceConfig serviceConfig4 = getServiceConfig(gjspc, "test.server4", NetUtils.LOCAL_HOST, 18089, HTTP_SCHEME, "jetty", CST_BASE_PATH2); providers.put(serviceConfig4.getName(), serviceConfig4); - ServiceConfig serviceConfig5 = getServiceConfig(javaBeanService, "test.server5", NetUtils.LOCAL_HOST, 18088, HTTP_SCHEME, "jetty"); providers.put(serviceConfig5.getName(), serviceConfig5); + ServiceConfig serviceConfig6 = getServiceConfig(parameterizedService, "test.server6", + NetUtils.LOCAL_HOST, + 18088, HTTP_SCHEME, "jetty"); + providers.put(serviceConfig6.getName(), serviceConfig6); + ServerConfig sc = new ServerConfig(); sc.setServiceMap(providers); sc.setApp("http-test-app"); @@ -294,6 +299,41 @@ public void testHttpRpcClientBasePathNotExist() { } } + @Test + public void testHttpRpcClientWithParameterizedBean() { + // 1)准备配置 + BackendConfig backendConfig = new BackendConfig(); + backendConfig.setName("serviceId"); + backendConfig.setRequestTimeout(REQUEST_TIMEOUT); + backendConfig.setMaxConns(MAX_CONNECTIONS); + backendConfig.setNamingUrl("ip://127.0.0.1:18088"); + backendConfig.setKeepAlive(false); + backendConfig.setConnsPerAddr(4); + backendConfig.setProtocol("http"); + ConsumerConfig consumerConfig = new ConsumerConfig<>(); + consumerConfig.setServiceInterface(GreeterParameterizedService.class); + consumerConfig.setBackendConfig(backendConfig); + try { + // 2)获取代理 + GreeterParameterizedService proxy = consumerConfig.getProxy(); + + for (int i = 0; i < 20; i++) { + final String msg = "I am"; + final String innerMsg = " ParameterizedBean!"; + + RpcClientContext context = new RpcClientContext(); + Map helloResponse = proxy + .sayHelloParameterized(context, RequestParameterizedBean.of("message", msg + innerMsg)); + Assert.assertNotNull(helloResponse); + String rspMessage = (String) helloResponse.get("message"); + logger.info("http rpc client request result: {}", rspMessage); + Assert.assertTrue(rspMessage.contains(msg)); + } + } finally { + backendConfig.stop(); + } + } + @Test public void testHttpRpcClientWithJavaBean() { BackendConfig backendConfig = new BackendConfig(); diff --git a/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/HttpRpcServerTest.java b/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/HttpRpcServerTest.java index daea209b2d..2266a622dc 100644 --- a/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/HttpRpcServerTest.java +++ b/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/HttpRpcServerTest.java @@ -1,7 +1,7 @@ /* * Tencent is pleased to support the open source community by making tRPC available. * - * Copyright (C) 2023 THL A29 Limited, a Tencent company. + * Copyright (C) 2023 THL A29 Limited, a Tencent company. * All rights reserved. * * If you have downloaded a copy of the tRPC source code from Tencent, @@ -40,11 +40,13 @@ import org.junit.Test; import tests.service.GreeterJavaBeanService; import tests.service.GreeterJsonService; +import tests.service.GreeterParameterizedService; import tests.service.GreeterService; import tests.service.HelloRequestProtocol.HelloRequest; import tests.service.TestBeanConvertWithGetMethodRsp; import tests.service.impl1.GreeterJavaBeanServiceImpl; import tests.service.impl1.GreeterJsonServiceImpl1; +import tests.service.impl1.GreeterParameterizedServiceImpl; import tests.service.impl1.GreeterServiceImpl1; public class HttpRpcServerTest { @@ -72,19 +74,27 @@ public static void startHttpServer() { javaBeanService.setServiceInterface(GreeterJavaBeanService.class); javaBeanService.setRef(new GreeterJavaBeanServiceImpl()); + ProviderConfig parameterizedService = new ProviderConfig<>(); + parameterizedService.setServiceInterface(GreeterParameterizedService.class); + parameterizedService.setRef(new GreeterParameterizedServiceImpl()); + HashMap providers = new HashMap<>(); - ServiceConfig serviceConfig1 = getServiceConfig(gspc, "test.server1", NetUtils.ANY_HOST, + ServiceConfig serviceConfig1 = getServiceConfig(gspc, "test.server1", NetUtils.LOCAL_HOST, 18090, HTTP_SCHEME, "jetty"); providers.put(serviceConfig1.getName(), serviceConfig1); - - ServiceConfig serviceConfig2 = getServiceConfig(gjspc, "test.server2", NetUtils.ANY_HOST, + ServiceConfig serviceConfig2 = getServiceConfig(gjspc, "test.server2", NetUtils.LOCAL_HOST, 18090, HTTP_SCHEME, "jetty"); providers.put(serviceConfig2.getName(), serviceConfig2); - ServiceConfig serviceConfig3 = getServiceConfig(javaBeanService, "test.server3", - NetUtils.ANY_HOST, 18090, HTTP_SCHEME, "jetty"); + NetUtils.LOCAL_HOST, + 18090, HTTP_SCHEME, "jetty"); providers.put(serviceConfig3.getName(), serviceConfig3); + ServiceConfig serviceConfig4 = getServiceConfig(parameterizedService, "test.server4", + NetUtils.LOCAL_HOST, + 18090, HTTP_SCHEME, "jetty"); + providers.put(serviceConfig4.getName(), serviceConfig4); + ServerConfig sc = new ServerConfig(); sc.setServiceMap(providers); sc.setApp("http-test-app"); @@ -558,6 +568,45 @@ public void testGetWithJavaBean() throws Exception { } } + @Test + public void testGetWithParameterizedBean() throws Exception { + String strUrl = + "http://localhost:18090/tencent.trpc.http.GreeterParameterizedService/sayHelloParameterized?message="; + URL url = new URL(strUrl + "hello"); + HttpURLConnection connection = null; + InputStream in = null; + + try { + connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + connection.setConnectTimeout(200); + connection.setReadTimeout(1000); + connection.setDoOutput(false); + connection.setDoInput(true); + + int responseCode = connection.getResponseCode(); + logger.info("response code is {}", responseCode); + + Assert.assertEquals(200, responseCode); + + in = connection.getInputStream(); + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + StreamUtils.copy(in, bos); + + logger.error("http response is: {}", + new String(bos.toByteArray(), StandardCharsets.UTF_8)); + } finally { + if (in != null) { + in.close(); + } + + if (connection != null) { + connection.disconnect(); + } + } + } + @Test public void testPostWithJavaBean() throws Exception { String strUrl = diff --git a/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutorTest.java b/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutorTest.java index 7d6f800618..53db1fe326 100644 --- a/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutorTest.java +++ b/trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/server/AbstractHttpExecutorTest.java @@ -20,7 +20,7 @@ import com.tencent.trpc.core.rpc.RpcInvocation; import com.tencent.trpc.core.rpc.common.RpcMethodInfo; import com.tencent.trpc.proto.http.common.HttpConstants; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.core.classloader.annotations.PowerMockIgnore; diff --git a/trpc-proto/trpc-proto-http/src/test/java/tests/service/GreeterParameterizedService.java b/trpc-proto/trpc-proto-http/src/test/java/tests/service/GreeterParameterizedService.java new file mode 100644 index 0000000000..4fcc6a5068 --- /dev/null +++ b/trpc-proto/trpc-proto-http/src/test/java/tests/service/GreeterParameterizedService.java @@ -0,0 +1,42 @@ +package tests.service; + +import com.tencent.trpc.core.rpc.RpcContext; +import com.tencent.trpc.core.rpc.anno.TRpcMethod; +import com.tencent.trpc.core.rpc.anno.TRpcService; +import java.util.Map; + +@TRpcService(name = "tencent.trpc.http.GreeterParameterizedService") +public interface GreeterParameterizedService { + + @TRpcMethod(name = "sayHelloParameterized") + Map sayHelloParameterized(RpcContext context, RequestParameterizedBean request); + + class RequestParameterizedBean { + + String message; + T data; + + public static RequestParameterizedBean of(String message, T data) { + RequestParameterizedBean bean = new RequestParameterizedBean<>(); + bean.setMessage(message); + bean.setData(data); + return bean; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + } +} diff --git a/trpc-proto/trpc-proto-http/src/test/java/tests/service/impl1/GreeterParameterizedServiceImpl.java b/trpc-proto/trpc-proto-http/src/test/java/tests/service/impl1/GreeterParameterizedServiceImpl.java new file mode 100644 index 0000000000..43b0ff2899 --- /dev/null +++ b/trpc-proto/trpc-proto-http/src/test/java/tests/service/impl1/GreeterParameterizedServiceImpl.java @@ -0,0 +1,20 @@ +package tests.service.impl1; + +import com.tencent.trpc.core.logger.Logger; +import com.tencent.trpc.core.logger.LoggerFactory; +import com.tencent.trpc.core.rpc.RpcContext; +import java.util.Collections; +import java.util.Map; +import tests.service.GreeterParameterizedService; + +public class GreeterParameterizedServiceImpl implements GreeterParameterizedService { + + private static final Logger logger = LoggerFactory.getLogger(GreeterParameterizedServiceImpl.class); + + @Override + public Map sayHelloParameterized(RpcContext context, RequestParameterizedBean request) { + logger.info("got hello json request, request is '{}'", request); + + return Collections.singletonMap("message", "Hi:" + request.getData()); + } +} diff --git a/trpc-proto/trpc-proto-standard/pom.xml b/trpc-proto/trpc-proto-standard/pom.xml index 1b21e8cd98..442370bbcd 100644 --- a/trpc-proto/trpc-proto-standard/pom.xml +++ b/trpc-proto/trpc-proto-standard/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-proto - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-proto/trpc-rpc-support/pom.xml b/trpc-proto/trpc-rpc-support/pom.xml index 385fec6fdf..6976275839 100644 --- a/trpc-proto/trpc-rpc-support/pom.xml +++ b/trpc-proto/trpc-rpc-support/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-proto - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-registry/pom.xml b/trpc-registry/pom.xml index 3d0cbda4dc..ae9b6ba2dc 100644 --- a/trpc-registry/pom.xml +++ b/trpc-registry/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-registry diff --git a/trpc-registry/trpc-registry-api/pom.xml b/trpc-registry/trpc-registry-api/pom.xml index d69a5bca82..4beab63096 100644 --- a/trpc-registry/trpc-registry-api/pom.xml +++ b/trpc-registry/trpc-registry-api/pom.xml @@ -7,7 +7,7 @@ trpc-registry com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-registry/trpc-registry-consul/pom.xml b/trpc-registry/trpc-registry-consul/pom.xml index 0927a12252..acabe3fa06 100644 --- a/trpc-registry/trpc-registry-consul/pom.xml +++ b/trpc-registry/trpc-registry-consul/pom.xml @@ -6,7 +6,7 @@ trpc-registry com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-registry/trpc-registry-nacos/pom.xml b/trpc-registry/trpc-registry-nacos/pom.xml index 9c93b41cad..56a21ca055 100644 --- a/trpc-registry/trpc-registry-nacos/pom.xml +++ b/trpc-registry/trpc-registry-nacos/pom.xml @@ -6,7 +6,7 @@ trpc-registry com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-registry/trpc-registry-open-polaris/pom.xml b/trpc-registry/trpc-registry-open-polaris/pom.xml index 3e79cdb702..ee6bebcfc3 100644 --- a/trpc-registry/trpc-registry-open-polaris/pom.xml +++ b/trpc-registry/trpc-registry-open-polaris/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-registry - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-registry/trpc-registry-zookeeper/pom.xml b/trpc-registry/trpc-registry-zookeeper/pom.xml index 94ac208d0a..b36f3d753f 100644 --- a/trpc-registry/trpc-registry-zookeeper/pom.xml +++ b/trpc-registry/trpc-registry-zookeeper/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-registry - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-selector/pom.xml b/trpc-selector/pom.xml index f410689cf4..ac5094cb05 100644 --- a/trpc-selector/pom.xml +++ b/trpc-selector/pom.xml @@ -19,6 +19,6 @@ trpc-parent com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 diff --git a/trpc-selector/trpc-selector-consul/pom.xml b/trpc-selector/trpc-selector-consul/pom.xml index f449a452d8..efd5659b34 100644 --- a/trpc-selector/trpc-selector-consul/pom.xml +++ b/trpc-selector/trpc-selector-consul/pom.xml @@ -27,7 +27,7 @@ trpc-selector com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 diff --git a/trpc-selector/trpc-selector-nacos/pom.xml b/trpc-selector/trpc-selector-nacos/pom.xml index 187a2aa616..e31d54e650 100644 --- a/trpc-selector/trpc-selector-nacos/pom.xml +++ b/trpc-selector/trpc-selector-nacos/pom.xml @@ -27,7 +27,7 @@ trpc-selector com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 diff --git a/trpc-selector/trpc-selector-open-polaris/pom.xml b/trpc-selector/trpc-selector-open-polaris/pom.xml index dff8a693e0..b64e8aa211 100644 --- a/trpc-selector/trpc-selector-open-polaris/pom.xml +++ b/trpc-selector/trpc-selector-open-polaris/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-selector - 1.4.0-SNAPSHOT + 2.0.1 jar @@ -39,8 +39,8 @@ slf4j-simple - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api com.tencent.trpc diff --git a/trpc-selector/trpc-selector-open-polaris/src/main/java/com/tencent/trpc/selector/polaris/PolarisSelector.java b/trpc-selector/trpc-selector-open-polaris/src/main/java/com/tencent/trpc/selector/polaris/PolarisSelector.java index 99f24a6982..e2170ac5a5 100644 --- a/trpc-selector/trpc-selector-open-polaris/src/main/java/com/tencent/trpc/selector/polaris/PolarisSelector.java +++ b/trpc-selector/trpc-selector-open-polaris/src/main/java/com/tencent/trpc/selector/polaris/PolarisSelector.java @@ -69,7 +69,7 @@ import java.util.concurrent.CompletionStage; import java.util.concurrent.Executor; import java.util.stream.Collectors; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; /** * Base open source polaris selector diff --git a/trpc-selector/trpc-selector-open-polaris/src/test/java/com/tencent/trpc/selector/open/polaris/RequestMetadataTest.java b/trpc-selector/trpc-selector-open-polaris/src/test/java/com/tencent/trpc/selector/open/polaris/RequestMetadataTest.java index aefa4180c4..a0cafdefac 100644 --- a/trpc-selector/trpc-selector-open-polaris/src/test/java/com/tencent/trpc/selector/open/polaris/RequestMetadataTest.java +++ b/trpc-selector/trpc-selector-open-polaris/src/test/java/com/tencent/trpc/selector/open/polaris/RequestMetadataTest.java @@ -21,7 +21,7 @@ import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.concurrent.ConcurrentMap; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/trpc-selector/trpc-selector-zookeeper/pom.xml b/trpc-selector/trpc-selector-zookeeper/pom.xml index d380adafe7..feb3300542 100644 --- a/trpc-selector/trpc-selector-zookeeper/pom.xml +++ b/trpc-selector/trpc-selector-zookeeper/pom.xml @@ -5,7 +5,7 @@ trpc-selector com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-spring-boot-starters/pom.xml b/trpc-spring-boot-starters/pom.xml index e4304b13a0..5fb70cf735 100644 --- a/trpc-spring-boot-starters/pom.xml +++ b/trpc-spring-boot-starters/pom.xml @@ -5,7 +5,7 @@ trpc-parent com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 trpc-spring-boot-starters diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/pom.xml b/trpc-spring-boot-starters/trpc-spring-boot-starter/pom.xml index d0c5554ba1..ace0cfd4d3 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/pom.xml +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ trpc-spring-boot-starters com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-spring-support/pom.xml b/trpc-spring-support/pom.xml index c052dba617..471b7a9c5b 100644 --- a/trpc-spring-support/pom.xml +++ b/trpc-spring-support/pom.xml @@ -5,7 +5,7 @@ trpc-parent com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-spring-support/trpc-spring-cloud-gateway/pom.xml b/trpc-spring-support/trpc-spring-cloud-gateway/pom.xml index 4ceababc9e..af69f9baef 100644 --- a/trpc-spring-support/trpc-spring-cloud-gateway/pom.xml +++ b/trpc-spring-support/trpc-spring-cloud-gateway/pom.xml @@ -6,7 +6,7 @@ trpc-spring-support com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 trpc-spring-cloud-gateway ${project.artifactId} diff --git a/trpc-spring-support/trpc-spring-nacos-autoconfigure/pom.xml b/trpc-spring-support/trpc-spring-nacos-autoconfigure/pom.xml index e7e8f9dbe1..f7b7a25906 100644 --- a/trpc-spring-support/trpc-spring-nacos-autoconfigure/pom.xml +++ b/trpc-spring-support/trpc-spring-nacos-autoconfigure/pom.xml @@ -6,7 +6,7 @@ trpc-spring-support com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-spring-support/trpc-spring-nacos-autoconfigure/src/main/resources/META-INF/spring.factories b/trpc-spring-support/trpc-spring-nacos-autoconfigure/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 0ae36d0e35..0000000000 --- a/trpc-spring-support/trpc-spring-nacos-autoconfigure/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -com.tencent.trpc.nacos.auto.configuration=\ - com.tencent.trpc.nacos.auto.configuration.NacosConfigAutoConfiguration diff --git a/trpc-spring-support/trpc-spring-nacos-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/trpc-spring-support/trpc-spring-nacos-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..b84e0c3943 --- /dev/null +++ b/trpc-spring-support/trpc-spring-nacos-autoconfigure/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.tencent.trpc.nacos.auto.configuration.NacosConfigAutoConfiguration \ No newline at end of file diff --git a/trpc-spring-support/trpc-spring/pom.xml b/trpc-spring-support/trpc-spring/pom.xml index 9936eabfa6..11a1468820 100644 --- a/trpc-spring-support/trpc-spring/pom.xml +++ b/trpc-spring-support/trpc-spring/pom.xml @@ -5,7 +5,7 @@ trpc-spring-support com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 trpc-spring diff --git a/trpc-spring-support/trpc-springmvc/pom.xml b/trpc-spring-support/trpc-springmvc/pom.xml index 78521b1f10..872e7fd080 100644 --- a/trpc-spring-support/trpc-springmvc/pom.xml +++ b/trpc-spring-support/trpc-springmvc/pom.xml @@ -5,7 +5,7 @@ trpc-spring-support com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 diff --git a/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcHandlerAdapter.java b/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcHandlerAdapter.java index d17905a81e..9228da838f 100644 --- a/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcHandlerAdapter.java +++ b/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcHandlerAdapter.java @@ -15,8 +15,8 @@ import com.tencent.trpc.core.exception.TRpcException; import com.tencent.trpc.core.rpc.common.RpcMethodInfoAndInvoker; import com.tencent.trpc.proto.http.server.AbstractHttpExecutor; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.web.servlet.HandlerAdapter; diff --git a/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcHttpCodec.java b/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcHttpCodec.java index 8ca5d35f7c..62c35450b5 100644 --- a/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcHttpCodec.java +++ b/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcHttpCodec.java @@ -12,7 +12,7 @@ package com.tencent.trpc.springmvc; import com.tencent.trpc.proto.http.common.HttpCodec; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; public class TRpcHttpCodec extends HttpCodec { diff --git a/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcServiceHandlerMapping.java b/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcServiceHandlerMapping.java index d1930a0a60..dbf4df98ff 100644 --- a/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcServiceHandlerMapping.java +++ b/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcServiceHandlerMapping.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicBoolean; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.core.Ordered; diff --git a/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcSpringMvcAutoConfiguration.java b/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcSpringMvcAutoConfiguration.java index 8437a88541..765e0be113 100644 --- a/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcSpringMvcAutoConfiguration.java +++ b/trpc-spring-support/trpc-springmvc/src/main/java/com/tencent/trpc/springmvc/TRpcSpringMvcAutoConfiguration.java @@ -23,6 +23,7 @@ import org.springframework.context.annotation.DependsOn; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.web.servlet.DispatcherServlet; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @AutoConfiguration @@ -30,6 +31,11 @@ @ConditionalOnClass(DispatcherServlet.class) public class TRpcSpringMvcAutoConfiguration implements WebMvcConfigurer { + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + configurer.setUseTrailingSlashMatch(true); + } + @Bean @ConditionalOnMissingBean @DependsOn(TRpcConfiguration.CONFIG_MANAGER_INITIALIZER_BEAN_NAME) diff --git a/trpc-test/pom.xml b/trpc-test/pom.xml index bb981f309a..bc21538b04 100644 --- a/trpc-test/pom.xml +++ b/trpc-test/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-test diff --git a/trpc-test/trpc-test-integration/pom.xml b/trpc-test/trpc-test-integration/pom.xml index 360296963a..ffd0d0b97f 100644 --- a/trpc-test/trpc-test-integration/pom.xml +++ b/trpc-test/trpc-test-integration/pom.xml @@ -5,7 +5,7 @@ trpc-test com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 4.0.0 @@ -17,7 +17,7 @@ 8 8 3.1.0 - 2.18 + 3.1.2 diff --git a/trpc-transport/pom.xml b/trpc-transport/pom.xml index e96100fe8b..26b4efddff 100644 --- a/trpc-transport/pom.xml +++ b/trpc-transport/pom.xml @@ -7,7 +7,7 @@ com.tencent.trpc trpc-parent - 1.4.0-SNAPSHOT + 2.0.1 trpc-transport diff --git a/trpc-transport/trpc-transport-http/pom.xml b/trpc-transport/trpc-transport-http/pom.xml index 093cdd2833..8310c5bccd 100644 --- a/trpc-transport/trpc-transport-http/pom.xml +++ b/trpc-transport/trpc-transport-http/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-transport - 1.4.0-SNAPSHOT + 2.0.1 jar @@ -71,6 +71,10 @@ httpclient test + + jakarta.servlet + jakarta.servlet-api + diff --git a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/ExecutorDispatcher.java b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/ExecutorDispatcher.java index 079d4d3a8c..5ed27416ba 100755 --- a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/ExecutorDispatcher.java +++ b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/ExecutorDispatcher.java @@ -14,10 +14,10 @@ import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; public class ExecutorDispatcher extends HttpServlet { diff --git a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/HttpExecutor.java b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/HttpExecutor.java index 2a418809c0..fcea4578af 100755 --- a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/HttpExecutor.java +++ b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/HttpExecutor.java @@ -12,9 +12,9 @@ package com.tencent.trpc.transport.http; import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; /** diff --git a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/common/ServletManager.java b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/common/ServletManager.java index 5af7f0ba88..742ca68e63 100644 --- a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/common/ServletManager.java +++ b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/common/ServletManager.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import javax.servlet.ServletContext; +import jakarta.servlet.ServletContext; /** * Utility class used to manage {@link ServletContext}s. diff --git a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/support/jetty/JettyHttp2Server.java b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/support/jetty/JettyHttp2Server.java index 9942ca3e44..3f7964fc68 100644 --- a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/support/jetty/JettyHttp2Server.java +++ b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/support/jetty/JettyHttp2Server.java @@ -43,7 +43,7 @@ public JettyHttp2Server(ProtocolConfig config, HttpExecutor executor) { @Override protected ServerConnector buildServerConnector(Server server, ProtocolConfig config, - SslContextFactory sslContextFactory, HttpConfiguration httpConfig, + SslContextFactory.Server sslContextFactory, HttpConfiguration httpConfig, HttpConfiguration httpsConfig) { // 1. Config the h2 factory HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(httpsConfig); diff --git a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/support/jetty/JettyHttpsServer.java b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/support/jetty/JettyHttpsServer.java index 1ab05c2436..03ab322c24 100644 --- a/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/support/jetty/JettyHttpsServer.java +++ b/trpc-transport/trpc-transport-http/src/main/java/com/tencent/trpc/transport/http/support/jetty/JettyHttpsServer.java @@ -26,7 +26,6 @@ import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.util.ssl.SslContextFactory.Client; /** @@ -50,7 +49,7 @@ public ServerConnector getServerConnector(Server server) { ProtocolConfig config = getConfig(); // 1. Configure SSL certificate, which uses TLS by default and is suitable for HTTPS and h2. - SslContextFactory sslContextFactory = new Client(); + SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); sslContextFactory.setKeyStorePath(String.valueOf(config.getExtMap().get(KEYSTORE_PATH))); sslContextFactory .setKeyStorePassword(String.valueOf(config.getExtMap().get(KEYSTORE_PASS))); @@ -82,7 +81,7 @@ public ServerConnector getServerConnector(Server server) { * @return the Jetty's {@link ServerConnector} */ protected ServerConnector buildServerConnector(Server server, ProtocolConfig config, - SslContextFactory sslContextFactory, HttpConfiguration httpConfig, + SslContextFactory.Server sslContextFactory, HttpConfiguration httpConfig, HttpConfiguration httpsConfig) { // 1. Configure ssl factory SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, HTTP1_SCHEME); diff --git a/trpc-transport/trpc-transport-http/src/test/java/com/tencent/trpc/transport/http/ExecutorDispatcherTest.java b/trpc-transport/trpc-transport-http/src/test/java/com/tencent/trpc/transport/http/ExecutorDispatcherTest.java index 3c59ecdcc2..2814e45454 100644 --- a/trpc-transport/trpc-transport-http/src/test/java/com/tencent/trpc/transport/http/ExecutorDispatcherTest.java +++ b/trpc-transport/trpc-transport-http/src/test/java/com/tencent/trpc/transport/http/ExecutorDispatcherTest.java @@ -14,9 +14,9 @@ import static org.mockito.Mockito.times; import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.junit.Test; import org.powermock.api.mockito.PowerMockito; diff --git a/trpc-transport/trpc-transport-http/src/test/java/com/tencent/trpc/transport/http/JettyServerDemo.java b/trpc-transport/trpc-transport-http/src/test/java/com/tencent/trpc/transport/http/JettyServerDemo.java index 9ffbfd9293..77b806696d 100644 --- a/trpc-transport/trpc-transport-http/src/test/java/com/tencent/trpc/transport/http/JettyServerDemo.java +++ b/trpc-transport/trpc-transport-http/src/test/java/com/tencent/trpc/transport/http/JettyServerDemo.java @@ -17,8 +17,8 @@ import com.tencent.trpc.core.extension.ExtensionLoader; import com.tencent.trpc.transport.http.spi.HttpServerFactory; import java.io.IOException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; public class JettyServerDemo { diff --git a/trpc-transport/trpc-transport-netty/pom.xml b/trpc-transport/trpc-transport-netty/pom.xml index 70cf9f605a..3657689b35 100644 --- a/trpc-transport/trpc-transport-netty/pom.xml +++ b/trpc-transport/trpc-transport-netty/pom.xml @@ -9,7 +9,7 @@ com.tencent.trpc trpc-transport - 1.4.0-SNAPSHOT + 2.0.1 jar diff --git a/trpc-validation/pom.xml b/trpc-validation/pom.xml index b9d57ed881..aebcec2129 100644 --- a/trpc-validation/pom.xml +++ b/trpc-validation/pom.xml @@ -8,7 +8,7 @@ trpc-parent com.tencent.trpc - 1.4.0-SNAPSHOT + 2.0.1 Trpc Parent Project ${project.version} diff --git a/trpc-validation/trpc-validation-pgv/pom.xml b/trpc-validation/trpc-validation-pgv/pom.xml index a4c32afb24..a4f1156429 100644 --- a/trpc-validation/trpc-validation-pgv/pom.xml +++ b/trpc-validation/trpc-validation-pgv/pom.xml @@ -8,7 +8,7 @@ com.tencent.trpc trpc-validation - 1.4.0-SNAPSHOT + 2.0.1 jar