Skip to content

fix(core): resolve universe domain and track explicit host in ServiceOptions - #15307

Open
whowes wants to merge 1 commit into
mainfrom
whowes/service-options-universe-domain
Open

whowes wants to merge 1 commit into
mainfrom
whowes/service-options-universe-domain

Conversation

@whowes

@whowes whowes commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Adds ServiceOptions.resolveUniverseDomain() and hasExplicitHost() so the universe helpers honor GOOGLE_CLOUD_UNIVERSE_DOMAIN. The ServiceOptions.Builder now only copies explicitly configured hosts, allowing toBuilder().setUniverseDomain() to recompute defaults.

When GOOGLE_CLOUD_UNIVERSE_DOMAIN is set to an empty string, resolveUniverseDomain() throws an IllegalArgumentException rather than falling back to googleapis.com. This avoids silently targeting googleapis.com on a misconfigured env var, at the cost of failing if a caller exports an empty string expecting it to act like unset. Fallback to googleapis.com is still active when GOOGLE_CLOUD_UNIVERSE_DOMAIN is unset.

@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 introduces changes to ServiceOptions to track whether a host was explicitly configured (via hasExplicitHost) and to resolve the universe domain using a defined precedence order (explicitly set, environment variable, or default). This allows proper recomputation of default hosts when modifying options like the universe domain. The feedback suggests marking the non-final hasExplicitHost field as volatile to ensure thread safety and safe publication under the Java Memory Model. Additionally, it recommends reordering the initialization in readObject to initialize the service factories before calling getDefaultHost(), avoiding potential NullPointerExceptions in subclass overrides during deserialization.

@whowes
whowes force-pushed the whowes/service-options-universe-domain branch 2 times, most recently from 1a0d265 to c8ae688 Compare December 1, 2026 01:08
@whowes
whowes force-pushed the whowes/service-options-universe-domain branch from c8ae688 to ff1a799 Compare December 1, 2026 02:05
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@whowes
whowes marked this pull request as ready for review December 1, 2026 07:10
@whowes
whowes requested a review from a team as a code owner December 1, 2026 07:10
@whowes
whowes requested a review from lqiu96 December 1, 2026 07:10

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