Repository navigation
Conversation
There was a problem hiding this comment.
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.
1a0d265 to
c8ae688
Compare
c8ae688 to
ff1a799
Compare
|
|





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.