Skip to content

chore: default local datacenter when using ephemeral adapter endpoint - #433

Merged
sakthivelmanii merged 3 commits into
mainfrom
fix/default-local-dc-and-adapter-cleanup
Nov 20, 2026
Merged

sakthivelmanii merged 3 commits into
mainfrom
fix/default-local-dc-and-adapter-cleanup

Conversation

@sakthivelmanii

@sakthivelmanii sakthivelmanii commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • After feat!: bind embedded proxy and sidecar listener to loopback by default #423 switched in-process SpannerCqlSession to bind an OS-assigned ephemeral loopback port and register that endpoint in programmaticContactPoints, zero-configuration callers (such as the README Quickstart example that omit both addContactPoint(...) and withLocalDatacenter(...)) fail with IllegalStateException: Since you provided explicit contact points, the local DC must be explicitly set.

Solution

  • Override SpannerCqlSessionBuilder.buildContext(...) to compose the caller's DriverConfigLoader with a fallback OptionsMap setting TypedDriverOption.LOAD_BALANCING_LOCAL_DATACENTER to "datacenter1" only when the caller provided neither a contact point (userContactPoint == null && !configContactPointProvided) nor a programmatic local datacenter, preserving config precedence and builder reuse without mutating programmaticArgumentsBuilder.
  • Add unit tests in SpannerCqlSessionBuilderTest verifying default local datacenter fallback, preservation of programmatic and config-supplied local datacenter values, and preservation of driver behavior when an explicit contact point is supplied.

@sakthivelmanii sakthivelmanii self-assigned this Nov 20, 2026
@sakthivelmanii sakthivelmanii changed the title fix: default local datacenter for ephemeral adapter endpoint and stop adapter on build failure chore: default local datacenter for ephemeral adapter endpoint and stop adapter on build failure Nov 20, 2026
@sakthivelmanii sakthivelmanii changed the title chore: default local datacenter for ephemeral adapter endpoint and stop adapter on build failure fix: default local datacenter when using ephemeral adapter endpoint Nov 20, 2026
@sakthivelmanii sakthivelmanii changed the title fix: default local datacenter when using ephemeral adapter endpoint chore: default local datacenter when using ephemeral adapter endpoint Nov 20, 2026
Infer the local datacenter from the server for zero-configuration
sessions, clean up the in-process adapter if session creation fails,
and fix configuration edge cases without weakening security checks.

Specifically:
- Treat internally generated adapter endpoints as implicit contact
  points so the driver infers the local datacenter instead of
  hardcoding "datacenter1", while keeping named execution profiles,
  custom configuration loaders, and reloading intact.
- Stop the started in-process adapter if building the CQL session fails
  synchronously or asynchronously.
- Honor a caller-supplied class loader when checking default
  configuration.
- Allow matching programmatic and configuration loopback contact points
  that refer to the same address and port, while still rejecting
  conflicting or multiple contact points.
- Intentionally keep the strict single-address check from the earlier
  security hardening: configuration contact points that resolve to
  multiple addresses on dual-stack machines (such as "localhost:9042")
  continue to be rejected.
@sakthivelmanii
sakthivelmanii merged commit 6edb60a into main Nov 20, 2026
21 checks passed
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.

2 participants