Copilot commented on code in PR #1288:
URL: https://github.com/apache/ratis/pull/1288#discussion_r2383967925
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java:
##########
@@ -60,42 +58,30 @@ public class GrpcServerProtocolClient implements Closeable {
//visible for using in log / error messages AND to use in instrumented tests
private final RaftPeerId raftPeerId;
- public GrpcServerProtocolClient(RaftPeer target, int connections, int
flowControlWindow,
- TimeDuration requestTimeout, GrpcTlsConfig tlsConfig, boolean
separateHBChannel) {
+ GrpcServerProtocolClient(RaftPeer target, int connections, int
flowControlWindow,
+ TimeDuration requestTimeout, SslContext sslContext, boolean
separateHBChannel) {
Review Comment:
The constructor visibility has been changed from `public` to
package-private. This is a breaking change that could affect external consumers
of this API.
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java:
##########
@@ -44,7 +42,7 @@
* This is a RaftClient implementation that supports streaming data to the raft
* ring. The stream implementation utilizes gRPC.
*/
-public class GrpcServerProtocolClient implements Closeable {
+class GrpcServerProtocolClient implements Closeable {
Review Comment:
The class visibility has been changed from `public` to package-private. This
is a breaking change that could affect external consumers of this API.
```suggestion
public class GrpcServerProtocolClient implements Closeable {
```
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcServerProtocolClient.java:
##########
@@ -60,42 +58,30 @@ public class GrpcServerProtocolClient implements Closeable {
//visible for using in log / error messages AND to use in instrumented tests
private final RaftPeerId raftPeerId;
- public GrpcServerProtocolClient(RaftPeer target, int connections, int
flowControlWindow,
- TimeDuration requestTimeout, GrpcTlsConfig tlsConfig, boolean
separateHBChannel) {
+ GrpcServerProtocolClient(RaftPeer target, int connections, int
flowControlWindow,
+ TimeDuration requestTimeout, SslContext sslContext, boolean
separateHBChannel) {
raftPeerId = target.getId();
LOG.info("Build channel for {}", target);
useSeparateHBChannel = separateHBChannel;
- channel = buildChannel(target, flowControlWindow, tlsConfig);
+ channel = buildChannel(target, flowControlWindow, sslContext);
blockingStub = RaftServerProtocolServiceGrpc.newBlockingStub(channel);
asyncStub = RaftServerProtocolServiceGrpc.newStub(channel);
if (useSeparateHBChannel) {
- hbChannel = buildChannel(target, flowControlWindow, tlsConfig);
+ hbChannel = buildChannel(target, flowControlWindow, sslContext);
hbAsyncStub = RaftServerProtocolServiceGrpc.newStub(hbChannel);
}
requestTimeoutDuration = requestTimeout;
- this.pool = new GrpcStubPool<RaftServerProtocolServiceStub>(target,
connections,
- ch -> RaftServerProtocolServiceGrpc.newStub(ch), tlsConfig);
+ this.pool = new GrpcStubPool<>(target, connections,
RaftServerProtocolServiceGrpc::newStub, sslContext);
}
- private ManagedChannel buildChannel(RaftPeer target, int flowControlWindow,
- GrpcTlsConfig tlsConfig) {
+ private ManagedChannel buildChannel(RaftPeer target, int flowControlWindow,
SslContext sslContext) {
NettyChannelBuilder channelBuilder =
NettyChannelBuilder.forTarget(target.getAddress());
// ignore any http proxy for grpc
channelBuilder.proxyDetector(uri -> null);
- if (tlsConfig!= null) {
- SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient();
- GrpcUtil.setTrustManager(sslContextBuilder, tlsConfig.getTrustManager());
- if (tlsConfig.getMtlsEnabled()) {
- GrpcUtil.setKeyManager(sslContextBuilder, tlsConfig.getKeyManager());
- }
- try {
-
channelBuilder.useTransportSecurity().sslContext(sslContextBuilder.build());
- } catch (Exception ex) {
- throw new IllegalArgumentException("Failed to build SslContext,
peerId=" + raftPeerId
- + ", tlsConfig=" + tlsConfig, ex);
- }
+ if (sslContext!= null) {
Review Comment:
Missing space before the inequality operator. Should be `if (sslContext !=
null) {`
```suggestion
if (sslContext != null) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]