Skip to content

Commit bbfe93b

Browse files
committed
Remove global SHARED_RESOURCE_CHANNELS.
1 parent 9efaa6a commit bbfe93b

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

s2a/src/main/java/io/grpc/s2a/channel/S2AHandshakerServiceChannel.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static java.util.concurrent.TimeUnit.SECONDS;
2121

2222
import com.google.common.annotations.VisibleForTesting;
23-
import com.google.common.collect.Maps;
2423
import io.grpc.CallOptions;
2524
import io.grpc.Channel;
2625
import io.grpc.ChannelCredentials;
@@ -35,14 +34,13 @@
3534
import io.netty.util.concurrent.DefaultThreadFactory;
3635
import java.time.Duration;
3736
import java.util.Optional;
38-
import java.util.concurrent.ConcurrentMap;
3937
import 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.
@@ -59,8 +57,6 @@
5957
*/
6058
@ThreadSafe
6159
public 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
/**

s2a/src/test/java/io/grpc/s2a/channel/S2AHandshakerServiceChannelTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void getChannelResource_twoEqualChannels() {
109109
S2AHandshakerServiceChannel.getChannelResource(
110110
"localhost:" + plaintextServer.getPort(),
111111
/* s2aChannelCredentials= */ Optional.empty());
112-
assertThat(resource).isEqualTo(resourceTwo);
112+
assertThat(resource).isNotEqualTo(resourceTwo);
113113
}
114114

115115
/** Same as getChannelResource_twoEqualChannels, but use mTLS. */
@@ -121,7 +121,7 @@ public void getChannelResource_mtlsTwoEqualChannels() throws Exception {
121121
Resource<Channel> resourceTwo =
122122
S2AHandshakerServiceChannel.getChannelResource(
123123
"localhost:" + mtlsServer.getPort(), getTlsChannelCredentials());
124-
assertThat(resource).isEqualTo(resourceTwo);
124+
assertThat(resource).isNotEqualTo(resourceTwo);
125125
}
126126

127127
/**

0 commit comments

Comments
 (0)