s2a: remove channelPool from S2AChannelCredentials builder. (#11573)

This commit is contained in:
Riya Mehta 2024-09-30 12:55:42 -07:00 committed by GitHub
parent a140e1bb0c
commit 7b4b109309
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 9 deletions

View File

@ -31,7 +31,6 @@ import io.grpc.netty.InternalProtocolNegotiator;
import io.grpc.s2a.channel.S2AHandshakerServiceChannel;
import io.grpc.s2a.handshaker.S2AIdentity;
import io.grpc.s2a.handshaker.S2AProtocolNegotiatorFactory;
import java.io.IOException;
import javax.annotation.concurrent.NotThreadSafe;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -59,13 +58,11 @@ public final class S2AChannelCredentials {
public static final class Builder {
private final String s2aAddress;
private final ChannelCredentials s2aChannelCredentials;
private ObjectPool<Channel> s2aChannelPool;
private @Nullable S2AIdentity localIdentity = null;
Builder(String s2aAddress, ChannelCredentials s2aChannelCredentials) {
this.s2aAddress = s2aAddress;
this.s2aChannelCredentials = s2aChannelCredentials;
this.s2aChannelPool = null;
}
/**
@ -107,16 +104,15 @@ public final class S2AChannelCredentials {
return this;
}
public ChannelCredentials build() throws IOException {
ObjectPool<Channel> s2aChannelPool =
SharedResourcePool.forResource(
S2AHandshakerServiceChannel.getChannelResource(s2aAddress, s2aChannelCredentials));
checkNotNull(s2aChannelPool, "s2aChannelPool");
this.s2aChannelPool = s2aChannelPool;
public ChannelCredentials build() {
return InternalNettyChannelCredentials.create(buildProtocolNegotiatorFactory());
}
InternalProtocolNegotiator.ClientFactory buildProtocolNegotiatorFactory() {
ObjectPool<Channel> s2aChannelPool =
SharedResourcePool.forResource(
S2AHandshakerServiceChannel.getChannelResource(s2aAddress, s2aChannelCredentials));
checkNotNull(s2aChannelPool, "s2aChannelPool");
return S2AProtocolNegotiatorFactory.createClientFactory(localIdentity, s2aChannelPool);
}
}