Skip to content

chore: align contact point parsing and validation with DataStax driver - #434

Closed
sakthivelmanii wants to merge 1 commit into
mainfrom
chore/contact-point-validation-parity
Closed

sakthivelmanii wants to merge 1 commit into
mainfrom
chore/contact-point-validation-parity

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

Problem

Following #423, SpannerCqlSessionBuilder.checkContactPoints() diverged from SessionBuilder (java-driver-core) in five loopback contact-point edge cases:

  • Dual-stack localhost:<port> in DriverConfigLoader / application.conf (resolving to both 127.0.0.1 and ::1) was rejected due to resolvedAddresses.length != 1.
  • Unresolved loopback InetSocketAddress values (e.g., InetSocketAddress.createUnresolved("localhost", 9042)) were rejected because getAddress() is null.
  • Supplying the identical loopback contact point in both config and addContactPoint(...) was rejected before deduplication.
  • Unbracketed IPv6 loopback strings (e.g., "::1:9042") in DriverConfigLoader were rejected by Guava's HostAndPort.fromString(...), whereas the DataStax driver accepts both ::1:9042 and [::1]:9042.
  • Calling the deprecated zero-arg defaultConfigLoader() ignored custom class loaders configured via withClassLoader(ClassLoader).

Solution

  • Validate all resolved addresses from InetAddress.getAllByName(host) are loopback and bind the embedded adapter to resolvedAddresses[0] (continuing to reject any mixed loopback/non-loopback resolution).
  • Resolve unresolved programmatic InetSocketAddress instances via InetAddress.getAllByName(getHostString()) and verify all resolved addresses are loopback.
  • Deduplicate validated config and programmatic InetSocketAddress entries in a Set before enforcing the single-contact-point limit.
  • Parse config host:port strings using lastIndexOf(':') with optional [...] IPv6 bracket stripping, matching the DataStax driver's parser while requiring a port in 1..65535.
  • Call defaultConfigLoader(programmaticArgumentsBuilder.build().getClassLoader()) so custom class loaders are honored when reading application.conf.
  • Add unit tests in SpannerCqlSessionBuilderTest covering all five cases.

@sakthivelmanii sakthivelmanii self-assigned this Nov 20, 2026
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