Skip to content

Commit 9650368

Browse files
committed
feat: Add comments for EndpointContext
1 parent 2df163f commit 9650368

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ public static Builder newBuilder() {
8282
return new AutoValue_EndpointContext.Builder().setSwitchToMtlsEndpointAllowed(false);
8383
}
8484

85-
// By default, the clientSettingsEndpoint value is the default_host endpoint
86-
// value configured in the service. Users can override this value by the Setter
87-
// exposed in the Client/Stub Settings or in the TransportChannelProvider.
8885
@VisibleForTesting
8986
void determineEndpoint() throws IOException {
9087
if (resolvedEndpoint != null && resolvedUniverseDomain != null) {
@@ -93,7 +90,7 @@ void determineEndpoint() throws IOException {
9390
MtlsProvider mtlsProvider = mtlsProvider() == null ? new MtlsProvider() : mtlsProvider();
9491
String customEndpoint =
9592
transportChannelEndpoint() != null ? transportChannelEndpoint() : clientSettingsEndpoint();
96-
// This means that there are no user configured endpoints, use the default endpoint
93+
// If there are no user configured endpoints, use the default endpoints
9794
if (customEndpoint == null) {
9895
if (switchToMtlsEndpointAllowed() && mtlsProvider != null) {
9996
resolvedEndpoint =
@@ -105,7 +102,8 @@ void determineEndpoint() throws IOException {
105102
return;
106103
}
107104
Matcher matcher = ENDPOINT_REGEX.matcher(customEndpoint);
108-
// Check if it matches the ENDPOINT_TEMPLATE format
105+
// Check if it matches the ENDPOINT_TEMPLATE format, otherwise use the
106+
// custom set endpoint
109107
if (!matcher.matches()) {
110108
resolvedEndpoint = customEndpoint;
111109
resolvedUniverseDomain = GOOGLE_DEFAULT_UNIVERSE;
@@ -126,11 +124,12 @@ void determineEndpoint() throws IOException {
126124
customEndpoint = customEndpoint.substring(8);
127125
}
128126

127+
// Parse the custom endpoint for the service name, universe domain, and the port
129128
int periodIndex = customEndpoint.indexOf('.');
130129
int colonIndex = customEndpoint.indexOf(':');
131130
String serviceName = customEndpoint.substring(0, periodIndex);
132131
String universeDomain;
133-
String port = "443";
132+
String port = DEFAULT_PORT;
134133
if (colonIndex != -1) {
135134
universeDomain = customEndpoint.substring(periodIndex + 1, colonIndex);
136135
port = customEndpoint.substring(colonIndex + 1);

0 commit comments

Comments
 (0)