Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions trpc-dependencies/trpc-dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,11 @@
<groupId>org.eclipse.jetty</groupId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<artifactId>jetty-alpn-java-server</artifactId>
<groupId>org.eclipse.jetty</groupId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<artifactId>jetty-alpn-openjdk8-server</artifactId>
<groupId>org.eclipse.jetty</groupId>
Expand Down
4 changes: 4 additions & 0 deletions trpc-proto/trpc-proto-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,9 @@
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<artifactId>jetty-alpn-java-server</artifactId>
<groupId>org.eclipse.jetty</groupId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -22,8 +22,9 @@
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager;
import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
import org.apache.hc.client5.http.ssl.ClientTlsStrategyBuilder;
import org.apache.hc.client5.http.ssl.DefaultHostnameVerifier;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.ssl.ConscryptClientTlsStrategy;
import org.apache.hc.core5.ssl.SSLContexts;

/**
Expand Down Expand Up @@ -63,7 +64,10 @@ protected void doOpen() {
// 2. Configure connection pool.
final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder
.create().useSystemProperties()
.setTlsStrategy(new ConscryptClientTlsStrategy(sslContext))
.setTlsStrategy(ClientTlsStrategyBuilder.create()
.setSslContext(sslContext)
.setHostnameVerifier(new DefaultHostnameVerifier())
.build())
.build();

// 3. Configure the client to force HTTPS protocol to use HTTP1 communication and H2 protocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import tests.service.GreeterJsonService;
import tests.service.GreeterService;
import tests.service.HelloRequestProtocol.HelloRequest;
Expand All @@ -53,7 +53,7 @@

private static Map<String, Object> extMap = new HashMap<>();

@BeforeClass
@BeforeAll

Check warning on line 56 in trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/Http2RpcClientTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] reported by reviewdog 🐶 缺少 Javadoc 。 Raw Output: /github/workspace/./trpc-proto/trpc-proto-http/src/test/java/com/tencent/trpc/proto/http/Http2RpcClientTest.java:56:5: info: 缺少 Javadoc 。 (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
public static void startHttpServer() {

String path = Http2RpcServerTest.class.getClassLoader().getResource("keystore.jks")
Expand Down Expand Up @@ -130,7 +130,7 @@
return serviceConfig;
}

@AfterClass
@AfterAll
public static void stopHttpServer() {
ConfigManager.stopTest();
if (serverConfig != null) {
Expand All @@ -154,7 +154,7 @@
backendConfig.setRequestTimeout(10000);
consumerConfig.setServiceInterface(GreeterService.class);
consumerConfig.setBackendConfig(backendConfig);
backendConfig.setNamingUrl("ip://127.0.0.1:18084");
backendConfig.setNamingUrl("ip://localhost:18084");
backendConfig.setKeepAlive(false);
backendConfig.setConnsPerAddr(4);
backendConfig.setProtocol(HTTP2_SCHEME);
Expand All @@ -166,10 +166,10 @@
for (int i = 0; i < 20; i++) {
RpcClientContext context = new RpcClientContext();
HelloResponse helloResponse = proxy.sayHello(context, createPbRequest(TEST_MESSAGE));
Assert.assertNotNull(helloResponse);
Assertions.assertNotNull(helloResponse);
String rspMessage = helloResponse.getMessage();
logger.info("http rpc client request result: {}", rspMessage);
Assert.assertTrue(rspMessage.contains(TEST_MESSAGE));
Assertions.assertTrue(rspMessage.contains(TEST_MESSAGE));
}
} finally {
backendConfig.stop();
Expand All @@ -185,7 +185,7 @@
backendConfig.setRequestTimeout(10000);
consumerConfig.setServiceInterface(GreeterService.class);
consumerConfig.setBackendConfig(backendConfig);
backendConfig.setNamingUrl("ip://127.0.0.1:18084");
backendConfig.setNamingUrl("ip://localhost:18084");
backendConfig.setKeepAlive(false);
backendConfig.setConnsPerAddr(4);
backendConfig.setProtocol(HTTP2_SCHEME);
Expand All @@ -198,7 +198,7 @@
RpcClientContext context = new RpcClientContext();
context.setOneWay(true);
HelloResponse helloResponse = proxy.sayHello(context, createPbRequest(TEST_MESSAGE));
Assert.assertNull(helloResponse);
Assertions.assertNull(helloResponse);
}
} finally {
backendConfig.stop();
Expand All @@ -214,7 +214,7 @@
backendConfig.setRequestTimeout(10000);
consumerConfig.setServiceInterface(GreeterService.class);
consumerConfig.setBackendConfig(backendConfig);
backendConfig.setNamingUrl("ip://127.0.0.1:18085");
backendConfig.setNamingUrl("ip://localhost:18085");
backendConfig.setKeepAlive(false);
backendConfig.setConnsPerAddr(4);
backendConfig.setProtocol(HTTP2_SCHEME);
Expand All @@ -227,10 +227,10 @@
for (int i = 0; i < 20; i++) {
RpcClientContext context = new RpcClientContext();
HelloResponse helloResponse = proxy.sayHello(context, createPbRequest(TEST_MESSAGE));
Assert.assertNotNull(helloResponse);
Assertions.assertNotNull(helloResponse);
String rspMessage = helloResponse.getMessage();
logger.info("http rpc client request result: {}", rspMessage);
Assert.assertTrue(rspMessage.contains(TEST_MESSAGE));
Assertions.assertTrue(rspMessage.contains(TEST_MESSAGE));
}
} finally {
backendConfig.stop();
Expand All @@ -246,7 +246,7 @@
backendConfig.setRequestTimeout(10000);
consumerConfig.setServiceInterface(GreeterJsonService.class);
consumerConfig.setBackendConfig(backendConfig);
backendConfig.setNamingUrl("ip://127.0.0.1:18085");
backendConfig.setNamingUrl("ip://localhost:18085");
backendConfig.setKeepAlive(false);
backendConfig.setConnsPerAddr(4);
backendConfig.setProtocol(HTTP2_SCHEME);
Expand All @@ -262,10 +262,10 @@

RpcClientContext context = new RpcClientContext();
Map helloResponse = proxy.sayHelloJson(context, obj);
Assert.assertNotNull(helloResponse);
Assertions.assertNotNull(helloResponse);
String rspMessage = (String) helloResponse.get("message");
logger.info("http rpc client request result: {}", rspMessage);
Assert.assertTrue(rspMessage.contains(TEST_MESSAGE));
Assertions.assertTrue(rspMessage.contains(TEST_MESSAGE));
}
} finally {
backendConfig.stop();
Expand All @@ -281,7 +281,7 @@
backendConfig.setRequestTimeout(10000);
consumerConfig.setServiceInterface(GreeterService.class);
consumerConfig.setBackendConfig(backendConfig);
backendConfig.setNamingUrl("ip://127.0.0.1:18085");
backendConfig.setNamingUrl("ip://localhost:18085");
backendConfig.setKeepAlive(false);
backendConfig.setConnsPerAddr(4);
backendConfig.setProtocol(HTTP2_SCHEME);
Expand All @@ -293,7 +293,7 @@

RpcClientContext context = new RpcClientContext();
HelloResponse helloResponse = proxy.sayHello(context, createPbRequest(TEST_MESSAGE));
Assert.fail("no exception thrown");
Assertions.fail("no exception thrown");
} catch (TRpcException e) {
logger.error("error: ", e);
} finally {
Expand All @@ -310,7 +310,7 @@
backendConfig.setRequestTimeout(10000);
consumerConfig.setServiceInterface(GreeterService.class);
consumerConfig.setBackendConfig(backendConfig);
backendConfig.setNamingUrl("ip://127.0.0.1:18086");
backendConfig.setNamingUrl("ip://localhost:18086");
backendConfig.setKeepAlive(false);
backendConfig.setConnsPerAddr(4);
backendConfig.setProtocol(HTTP2_SCHEME);
Expand All @@ -322,9 +322,9 @@

RpcClientContext context = new RpcClientContext();
proxy.sayHello(context, createPbRequest(TEST_MESSAGE));
Assert.fail("no exception thrown");
Assertions.fail("no exception thrown");
} catch (TRpcException e) {
Assert.assertEquals(0, e.getBizCode());
Assertions.assertEquals(0, e.getBizCode());
} finally {
backendConfig.stop();
}
Expand All @@ -339,7 +339,7 @@
backendConfig.setRequestTimeout(10000);
consumerConfig.setServiceInterface(GreeterService.class);
consumerConfig.setBackendConfig(backendConfig);
backendConfig.setNamingUrl("ip://127.0.0.1:18084");
backendConfig.setNamingUrl("ip://localhost:18084");
backendConfig.setKeepAlive(false);
backendConfig.setConnsPerAddr(4);
backendConfig.setProtocol(HTTP2_SCHEME);
Expand All @@ -351,9 +351,9 @@
for (int i = 0; i < 20; i++) {
RpcClientContext context = new RpcClientContext();
String helloResponse = proxy.sayBlankHello(context, createPbRequest(TEST_MESSAGE));
Assert.assertNull(helloResponse);
Assertions.assertNull(helloResponse);
logger.info("http rpc client request result: {}", helloResponse);
Assert.assertTrue(StringUtils.isEmpty(helloResponse));
Assertions.assertTrue(StringUtils.isEmpty(helloResponse));
}
} finally {
backendConfig.stop();
Expand Down
Loading
Loading