2020import static java .util .concurrent .TimeUnit .SECONDS ;
2121
2222import com .google .common .annotations .VisibleForTesting ;
23- import com .google .common .collect .Maps ;
2423import io .grpc .CallOptions ;
2524import io .grpc .Channel ;
2625import io .grpc .ChannelCredentials ;
3534import io .netty .util .concurrent .DefaultThreadFactory ;
3635import java .time .Duration ;
3736import java .util .Optional ;
38- import java .util .concurrent .ConcurrentMap ;
3937import javax .annotation .concurrent .ThreadSafe ;
4038
4139/**
42- * Provides APIs for managing gRPC channels to S2A servers . Each channel is local and plaintext. If
43- * credentials are provided, they are used to secure the channel.
40+ * Provides APIs for managing gRPC channels to an S2A server . Each channel is local and plaintext.
41+ * If credentials are provided, they are used to secure the channel.
4442 *
45- * <p>This is done as follows: for each S2A server, provides an implementation of gRPC's {@link
43+ * <p>This is done as follows: for an S2A server, provides an implementation of gRPC's {@link
4644 * SharedResourceHolder.Resource} interface called a {@code Resource<Channel>}. A {@code
4745 * Resource<Channel>} is a factory for creating gRPC channels to the S2A server at a given address,
4846 * and a channel must be returned to the {@code Resource<Channel>} when it is no longer needed.
5957 */
6058@ ThreadSafe
6159public final class S2AHandshakerServiceChannel {
62- private static final ConcurrentMap <String , Resource <Channel >> SHARED_RESOURCE_CHANNELS =
63- Maps .newConcurrentMap ();
6460 private static final Duration DELEGATE_TERMINATION_TIMEOUT = Duration .ofSeconds (2 );
6561 private static final Duration CHANNEL_SHUTDOWN_TIMEOUT = Duration .ofSeconds (10 );
6662
@@ -76,8 +72,7 @@ public final class S2AHandshakerServiceChannel {
7672 public static Resource <Channel > getChannelResource (
7773 String s2aAddress , Optional <ChannelCredentials > s2aChannelCredentials ) {
7874 checkNotNull (s2aAddress );
79- return SHARED_RESOURCE_CHANNELS .computeIfAbsent (
80- s2aAddress , channelResource -> new ChannelResource (s2aAddress , s2aChannelCredentials ));
75+ return new ChannelResource (s2aAddress , s2aChannelCredentials );
8176 }
8277
8378 /**
0 commit comments