Skip to content

Commit e10f10c

Browse files
committed
fix(spanner): moved mTLSContext configurator from builder to construtor
1 parent 2d65e88 commit e10f10c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,17 @@ protected SpannerOptions(Builder builder) {
741741

742742
transportChannelExecutorThreadNameFormat = builder.transportChannelExecutorThreadNameFormat;
743743
channelProvider = builder.channelProvider;
744-
channelConfigurator = builder.channelConfigurator;
744+
if (builder.mTLSContext != null) {
745+
channelConfigurator =
746+
channelBuilder -> {
747+
if (channelBuilder instanceof NettyChannelBuilder) {
748+
((NettyChannelBuilder) channelBuilder).sslContext(builder.mTLSContext);
749+
}
750+
return channelBuilder;
751+
};
752+
} else {
753+
channelConfigurator = builder.channelConfigurator;
754+
}
745755
interceptorProvider = builder.interceptorProvider;
746756
sessionPoolOptions =
747757
builder.sessionPoolOptions != null
@@ -1620,15 +1630,6 @@ public SpannerOptions build() {
16201630
// As we are using plain text, we should never send any credentials.
16211631
this.setCredentials(NoCredentials.getInstance());
16221632
}
1623-
if (mTLSContext != null) {
1624-
this.setChannelConfigurator(
1625-
builder -> {
1626-
if (builder instanceof NettyChannelBuilder) {
1627-
((NettyChannelBuilder) builder).sslContext(mTLSContext);
1628-
}
1629-
return builder;
1630-
});
1631-
}
16321633
if (this.numChannels == null) {
16331634
this.numChannels =
16341635
this.grpcGcpExtensionEnabled ? GRPC_GCP_ENABLED_DEFAULT_CHANNELS : DEFAULT_CHANNELS;

0 commit comments

Comments
 (0)