Skip to content

Commit 44da596

Browse files
move/update warning for ServerInfo as key to class-level Javadoc
1 parent bf8e597 commit 44da596

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

xds/src/main/java/io/grpc/xds/GrpcXdsTransportFactory.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@
3535
import java.util.concurrent.ConcurrentHashMap;
3636
import java.util.concurrent.TimeUnit;
3737

38+
/**
39+
* A factory for creating gRPC-based transports for xDS communication.
40+
*
41+
* <p>WARNING: This class reuses channels when possible, based on the provided {@link
42+
* Bootstrapper.ServerInfo} with important considerations. The {@link Bootstrapper.ServerInfo}
43+
* includes {@link ChannelCredentials}, which is compared by reference equality. This means every
44+
* {@link Bootstrapper.BootstrapInfo} would have non-equal copies of {@link
45+
* Bootstrapper.ServerInfo}, even if they all represent the same xDS server configuration. For gRPC
46+
* name resolution with the {@code xds} and {@code google-c2p} scheme, this transport sharing works
47+
* as expected as it internally reuses a single {@link Bootstrapper.BootstrapInfo} instance.
48+
* Otherwise, new transports would be created for each {@link Bootstrapper.ServerInfo} despite them
49+
* possibly representing the same xDS server configuration and defeating the purpose of transport
50+
* sharing.
51+
*/
3852
final class GrpcXdsTransportFactory implements XdsTransportFactory {
3953

4054
private final CallCredentials callCredentials;
@@ -44,14 +58,6 @@ final class GrpcXdsTransportFactory implements XdsTransportFactory {
4458
// NOTE: ConcurrentHashMap is used as a per-entry lock and all reads and writes must be a mutation
4559
// via the ConcurrentHashMap APIs to acquire the per-entry lock in order to ensure thread safety
4660
// for reference counting of each GrpcXdsTransport instance.
47-
//
48-
// WARNING: ServerInfo includes ChannelCredentials, which is compared by reference equality.
49-
// This means every BootstrapInfo would have non-equal copies of ServerInfo, even if they all
50-
// represent the same xDS server configuration. For gRPC name resolution with the `xds` and
51-
// `google-c2p` scheme, this transport sharing works as expected as it internally reuses a single
52-
// BootstrapInfo instance. Otherwise, new transports would be created for each ServerInfo despite
53-
// them possibly representing the same xDS server configuration and defeating the purpose of
54-
// transport sharing.
5561
private static final Map<Bootstrapper.ServerInfo, GrpcXdsTransport> xdsServerInfoToTransportMap =
5662
new ConcurrentHashMap<>();
5763

0 commit comments

Comments
 (0)