Skip to content

Commit 74750a1

Browse files
committed
gemini suggested code changes
1 parent 87408e4 commit 74750a1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,13 +1551,13 @@ public Builder setHost(String host) {
15511551

15521552
@ExperimentalApi("https://github.com/googleapis/java-spanner/pull/3676")
15531553
public Builder setExperimentalHost(String host) {
1554-
if (usePlainText && !host.startsWith("http")) {
1554+
if (this.usePlainText && !host.startsWith("http")) {
15551555
host = "http://" + host;
15561556
}
15571557
super.setHost(host);
15581558
super.setProjectId(EXPERIMENTAL_HOST_PROJECT_ID);
15591559
setSessionPoolOption(SessionPoolOptions.newBuilder().setExperimentalHost().build());
1560-
experimentalHost = host;
1560+
this.experimentalHost = host;
15611561
return this;
15621562
}
15631563

@@ -1623,15 +1623,15 @@ public Builder useClientCert(String clientCertificate, String clientCertificateK
16231623
* the transport to use plaintext (no TLS) and will set credentials to {@link
16241624
* com.google.cloud.NoCredentials} to avoid sending authentication over an unsecured channel.
16251625
*/
1626-
@ExperimentalApi("https://github.com/googleapis/java-spanner/pull/3574")
1626+
@ExperimentalApi("https://github.com/googleapis/java-spanner/pull/4264")
16271627
public Builder usePlainText() {
1628+
this.usePlainText = true;
16281629
this.setChannelConfigurator(ManagedChannelBuilder::usePlaintext)
16291630
.setCredentials(NoCredentials.getInstance());
1630-
if (this.experimentalHost != null && !this.experimentalHost.startsWith("http")) {
1631-
this.experimentalHost = "http://" + this.experimentalHost;
1632-
super.setHost(this.experimentalHost);
1631+
if (this.experimentalHost != null) {
1632+
// Re-apply host settings to ensure http:// is prepended.
1633+
setExperimentalHost(this.experimentalHost);
16331634
}
1634-
this.usePlainText = true;
16351635
return this;
16361636
}
16371637

0 commit comments

Comments
 (0)