diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClient.java b/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClient.java index 0d32233d0..7261799da 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClient.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClient.java @@ -154,12 +154,12 @@ private String determineEndpoint(Builder builder) { * Domain in the Credentials */ public void validateUniverseDomain() throws IOException { - String expectedUniverseDomain; - if (!(httpRequestInitializer instanceof HttpCredentialsAdapter)) { - expectedUniverseDomain = Credentials.GOOGLE_DEFAULT_UNIVERSE; - } else { + String expectedUniverseDomain = Credentials.GOOGLE_DEFAULT_UNIVERSE; + if (httpRequestInitializer instanceof HttpCredentialsAdapter) { Credentials credentials = ((HttpCredentialsAdapter) httpRequestInitializer).getCredentials(); - expectedUniverseDomain = credentials.getUniverseDomain(); + if (credentials != null) { + expectedUniverseDomain = credentials.getUniverseDomain(); + } } if (!expectedUniverseDomain.equals(getUniverseDomain())) { throw new IllegalStateException( @@ -409,7 +409,7 @@ public abstract static class Builder { String universeDomain; /** - * Regex pattern to check if the URL passed in matches the default endpoint confgured from a + * Regex pattern to check if the URL passed in matches the default endpoint configured from a * discovery doc. Follows the format of `https://{serviceName}(.mtls).googleapis.com/` */ Pattern defaultEndpointRegex = @@ -424,8 +424,8 @@ public abstract static class Builder { * done via {@link #setRootUrl(String)}. * *
For other uses cases that touch this Builder's constructor directly, check if the rootUrl - * passed in references the Google Default Universe (GDU). Any rootUrl value that is not set in - * the GDU is a user configured endpoint. + * passed matches the default endpoint regex. If it doesn't match, it is a user configured + * endpoint. */ boolean isUserConfiguredEndpoint;