Repository navigation
fix(spanner): resolve default host from universeDomain in ConnectionOptions.getChannelProvider() - #15135
fix(spanner): resolve default host from universeDomain in ConnectionOptions.getChannelProvider()#15135sakthivelmanii wants to merge 1 commit into
Conversation
…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.
There was a problem hiding this comment.
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.
| ConnectionOptions poolOptions = | ||
| ConnectionOptions.newBuilder() | ||
| .setUri( | ||
| baseUri | ||
| + "?universeDomain=abc.goog;usePlainText=true;channelProvider=com.google.cloud.spanner.connection.TestChannelProvider") | ||
| .setConfigurator( |
There was a problem hiding this comment.
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(
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.