From 965036812676e8534917567cf8e2de186b0bdcd2 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Fri, 3 Nov 2023 18:13:47 -0400 Subject: [PATCH] feat: Add comments for EndpointContext --- .../java/com/google/api/gax/rpc/EndpointContext.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java b/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java index c107fa01d1..78214d3657 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java @@ -82,9 +82,6 @@ public static Builder newBuilder() { return new AutoValue_EndpointContext.Builder().setSwitchToMtlsEndpointAllowed(false); } - // By default, the clientSettingsEndpoint value is the default_host endpoint - // value configured in the service. Users can override this value by the Setter - // exposed in the Client/Stub Settings or in the TransportChannelProvider. @VisibleForTesting void determineEndpoint() throws IOException { if (resolvedEndpoint != null && resolvedUniverseDomain != null) { @@ -93,7 +90,7 @@ void determineEndpoint() throws IOException { MtlsProvider mtlsProvider = mtlsProvider() == null ? new MtlsProvider() : mtlsProvider(); String customEndpoint = transportChannelEndpoint() != null ? transportChannelEndpoint() : clientSettingsEndpoint(); - // This means that there are no user configured endpoints, use the default endpoint + // If there are no user configured endpoints, use the default endpoints if (customEndpoint == null) { if (switchToMtlsEndpointAllowed() && mtlsProvider != null) { resolvedEndpoint = @@ -105,7 +102,8 @@ void determineEndpoint() throws IOException { return; } Matcher matcher = ENDPOINT_REGEX.matcher(customEndpoint); - // Check if it matches the ENDPOINT_TEMPLATE format + // Check if it matches the ENDPOINT_TEMPLATE format, otherwise use the + // custom set endpoint if (!matcher.matches()) { resolvedEndpoint = customEndpoint; resolvedUniverseDomain = GOOGLE_DEFAULT_UNIVERSE; @@ -126,11 +124,12 @@ void determineEndpoint() throws IOException { customEndpoint = customEndpoint.substring(8); } + // Parse the custom endpoint for the service name, universe domain, and the port int periodIndex = customEndpoint.indexOf('.'); int colonIndex = customEndpoint.indexOf(':'); String serviceName = customEndpoint.substring(0, periodIndex); String universeDomain; - String port = "443"; + String port = DEFAULT_PORT; if (colonIndex != -1) { universeDomain = customEndpoint.substring(periodIndex + 1, colonIndex); port = customEndpoint.substring(colonIndex + 1);