Skip to content

Commit

Permalink
fix(spanner): moved mTLSContext configurator from builder to construt…
Browse files Browse the repository at this point in the history
…or (#3605)

* fix(spanner): moved mTLSContext configurator from builder to construtor

* builder configurator properties retained when not null
  • Loading branch information
sagnghos authored Jan 23, 2025
1 parent 3e27251 commit ac7c30b
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,20 @@ protected SpannerOptions(Builder builder) {

transportChannelExecutorThreadNameFormat = builder.transportChannelExecutorThreadNameFormat;
channelProvider = builder.channelProvider;
channelConfigurator = builder.channelConfigurator;
if (builder.mTLSContext != null) {
channelConfigurator =
channelBuilder -> {
if (builder.channelConfigurator != null) {
channelBuilder = builder.channelConfigurator.apply(channelBuilder);
}
if (channelBuilder instanceof NettyChannelBuilder) {
((NettyChannelBuilder) channelBuilder).sslContext(builder.mTLSContext);
}
return channelBuilder;
};
} else {
channelConfigurator = builder.channelConfigurator;
}
interceptorProvider = builder.interceptorProvider;
sessionPoolOptions =
builder.sessionPoolOptions != null
Expand Down Expand Up @@ -1620,15 +1633,6 @@ public SpannerOptions build() {
// As we are using plain text, we should never send any credentials.
this.setCredentials(NoCredentials.getInstance());
}
if (mTLSContext != null) {
this.setChannelConfigurator(
builder -> {
if (builder instanceof NettyChannelBuilder) {
((NettyChannelBuilder) builder).sslContext(mTLSContext);
}
return builder;
});
}
if (this.numChannels == null) {
this.numChannels =
this.grpcGcpExtensionEnabled ? GRPC_GCP_ENABLED_DEFAULT_CHANNELS : DEFAULT_CHANNELS;
Expand Down

0 comments on commit ac7c30b

Please sign in to comment.