@@ -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
@@ -1617,15 +1617,15 @@ public Builder useClientCert(String clientCertificate, String clientCertificateK
16171617 * the transport to use plaintext (no TLS) and will set credentials to {@link
16181618 * com.google.cloud.NoCredentials} to avoid sending authentication over an unsecured channel.
16191619 */
1620- @ ExperimentalApi ("https://github.com/googleapis/java-spanner/pull/3574 " )
1620+ @ ExperimentalApi ("https://github.com/googleapis/java-spanner/pull/4264 " )
16211621 public Builder usePlainText () {
1622+ this .usePlainText = true ;
16221623 this .setChannelConfigurator (ManagedChannelBuilder ::usePlaintext )
16231624 .setCredentials (NoCredentials .getInstance ());
1624- if (this .experimentalHost != null && ! this . experimentalHost . startsWith ( "http" ) ) {
1625- this . experimentalHost = " http://" + this . experimentalHost ;
1626- super . setHost (this .experimentalHost );
1625+ if (this .experimentalHost != null ) {
1626+ // Re-apply host settings to ensure http:// is prepended.
1627+ setExperimentalHost (this .experimentalHost );
16271628 }
1628- this .usePlainText = true ;
16291629 return this ;
16301630 }
16311631
0 commit comments