From de1f11b614779046d5ce80128070ce9cd0e369d8 Mon Sep 17 00:00:00 2001 From: sagnghos Date: Tue, 20 May 2025 09:13:37 +0000 Subject: [PATCH] chore: enable experimentalHost support for pgAdapter --- .../google/cloud/spanner/connection/SpannerPool.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/SpannerPool.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/SpannerPool.java index 60b1acfb60a..8c521b7500e 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/SpannerPool.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/SpannerPool.java @@ -163,6 +163,7 @@ static class SpannerPoolKey { private final boolean enableEndToEndTracing; private final String clientCertificate; private final String clientCertificateKey; + private final boolean isExperimentalHost; @VisibleForTesting static SpannerPoolKey of(ConnectionOptions options) { @@ -196,6 +197,7 @@ private SpannerPoolKey(ConnectionOptions options) throws IOException { this.enableEndToEndTracing = options.isEndToEndTracingEnabled(); this.clientCertificate = options.getClientCertificate(); this.clientCertificateKey = options.getClientCertificateKey(); + this.isExperimentalHost = options.isExperimentalHost(); } @Override @@ -220,7 +222,8 @@ public boolean equals(Object o) { && Objects.equals(this.enableApiTracing, other.enableApiTracing) && Objects.equals(this.enableEndToEndTracing, other.enableEndToEndTracing) && Objects.equals(this.clientCertificate, other.clientCertificate) - && Objects.equals(this.clientCertificateKey, other.clientCertificateKey); + && Objects.equals(this.clientCertificateKey, other.clientCertificateKey) + && Objects.equals(this.isExperimentalHost, other.isExperimentalHost); } @Override @@ -241,7 +244,8 @@ public int hashCode() { this.enableApiTracing, this.enableEndToEndTracing, this.clientCertificate, - this.clientCertificateKey); + this.clientCertificateKey, + this.isExperimentalHost); } } @@ -405,6 +409,9 @@ Spanner createSpanner(SpannerPoolKey key, ConnectionOptions options) { if (key.clientCertificate != null && key.clientCertificateKey != null) { builder.useClientCert(key.clientCertificate, key.clientCertificateKey); } + if (key.isExperimentalHost) { + builder.setExperimentalHost(key.host); + } if (options.getConfigurator() != null) { options.getConfigurator().configure(builder); }