@@ -66,20 +66,19 @@ public final class S2AProtocolNegotiatorFactory {
6666 * @return a factory for creating a client-side protocol negotiator.
6767 */
6868 public static InternalProtocolNegotiator.ClientFactory createClientFactory(
69- Optional< S2AIdentity> localIdentity, ObjectPool<Channel> s2aChannelPool) {
69+ @Nullable S2AIdentity localIdentity, ObjectPool<Channel> s2aChannelPool) {
7070 checkNotNull(s2aChannelPool, "S2A channel pool should not be null.");
71- checkNotNull(localIdentity, "Local identity should not be null on the client side.");
7271 S2AChannelPool channelPool = S2AGrpcChannelPool.create(s2aChannelPool);
7372 return new S2AClientProtocolNegotiatorFactory(localIdentity, channelPool);
7473 }
7574
7675 static final class S2AClientProtocolNegotiatorFactory
7776 implements InternalProtocolNegotiator.ClientFactory {
78- private final Optional< S2AIdentity> localIdentity;
77+ private final @Nullable S2AIdentity localIdentity;
7978 private final S2AChannelPool channelPool;
8079
8180 S2AClientProtocolNegotiatorFactory(
82- Optional< S2AIdentity> localIdentity, S2AChannelPool channelPool) {
81+ @Nullable S2AIdentity localIdentity, S2AChannelPool channelPool) {
8382 this.localIdentity = localIdentity;
8483 this.channelPool = channelPool;
8584 }
@@ -105,10 +104,13 @@ static final class S2AProtocolNegotiator implements ProtocolNegotiator {
105104 MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1));
106105
107106 static S2AProtocolNegotiator createForClient(
108- S2AChannelPool channelPool, Optional< S2AIdentity> localIdentity) {
107+ S2AChannelPool channelPool, @Nullable S2AIdentity localIdentity) {
109108 checkNotNull(channelPool, "Channel pool should not be null.");
110- checkNotNull(localIdentity, "Local identity should not be null on the client side.");
111- return new S2AProtocolNegotiator(channelPool, localIdentity);
109+ if (localIdentity == null) {
110+ return new S2AProtocolNegotiator(channelPool, Optional.empty());
111+ } else {
112+ return new S2AProtocolNegotiator(channelPool, Optional.of(localIdentity));
113+ }
112114 }
113115
114116 @VisibleForTesting
0 commit comments