Skip to content

fix(spanner): resolve default host from universeDomain in ConnectionOptions.getChannelProvider() - #15135

Open
sakthivelmanii wants to merge 1 commit into
mainfrom
fix-channel-provider-universe-domain
Open

sakthivelmanii wants to merge 1 commit into
mainfrom
fix-channel-provider-universe-domain

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

When no explicit host or endpoint is configured, ConnectionOptions.getChannelProvider() previously fell back to a hardcoded https://spanner.googleapis.com URL even when a custom universeDomain was specified. Derive the default host from the configured universeDomain (falling back to googleapis.com when unset or empty), matching SpannerOptions.getDefaultHost(), and avoid invoking getChannelProvider() twice in SpannerPool.

…ptions.getChannelProvider()

When no explicit host or endpoint is configured, ConnectionOptions.getChannelProvider()
previously fell back to a hardcoded https://spanner.googleapis.com URL even when a
custom universeDomain was specified. Derive the default host from the configured
universeDomain (falling back to googleapis.com when unset or empty), matching
SpannerOptions.getDefaultHost(), and avoid invoking getChannelProvider() twice in
SpannerPool.
@sakthivelmanii
sakthivelmanii requested review from a team as code owners November 21, 2026 22:48

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for universe domains when resolving the default host in ConnectionOptions. It replaces the hardcoded DEFAULT_HOST with a dynamically constructed host based on the configured universe domain, falling back to the default Google universe when none is specified. Corresponding tests have been added to verify this behavior under various configurations. Feedback on the changes highlights that the newly added test poolOptions is missing explicit credentials, which could cause test failures in environments without Application Default Credentials (ADC) configured.

Comment on lines +1477 to +1482
ConnectionOptions poolOptions =
ConnectionOptions.newBuilder()
.setUri(
baseUri
+ "?universeDomain=abc.goog;usePlainText=true;channelProvider=com.google.cloud.spanner.connection.TestChannelProvider")
.setConfigurator(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The poolOptions builder is missing an explicit .setCredentials(NoCredentials.getInstance()) call. Without this, the test will attempt to load Application Default Credentials (ADC) from the environment when SpannerPool.INSTANCE.getSpanner is invoked. In environments where ADC is not configured (such as certain CI/CD pipelines), this will cause the test to fail with an IOException. Adding NoCredentials ensures the test remains hermetic and environment-independent, consistent with the other test cases in this file.

          ConnectionOptions poolOptions =
              ConnectionOptions.newBuilder()
                  .setUri(
                      baseUri
                          + "?universeDomain=abc.goog;usePlainText=true;channelProvider=com.google.cloud.spanner.connection.TestChannelProvider")
                  .setCredentials(NoCredentials.getInstance())
                  .setConfigurator(

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant