@@ -155,6 +155,7 @@ static class SpannerPoolKey {
155155 private final SessionPoolOptions sessionPoolOptions ;
156156 private final Integer numChannels ;
157157 private final Boolean enableDynamicChannelPool ;
158+ private final Boolean enableGrpcGcp ;
158159 private final Integer dcpMinChannels ;
159160 private final Integer dcpMaxChannels ;
160161 private final Integer dcpInitialChannels ;
@@ -197,6 +198,7 @@ private SpannerPoolKey(ConnectionOptions options) throws IOException {
197198 : options .getSessionPoolOptions ();
198199 this .numChannels = options .getNumChannels ();
199200 this .enableDynamicChannelPool = options .isEnableDynamicChannelPool ();
201+ this .enableGrpcGcp = options .isEnableGrpcGcp ();
200202 this .dcpMinChannels = options .getDcpMinChannels ();
201203 this .dcpMaxChannels = options .getDcpMaxChannels ();
202204 this .dcpInitialChannels = options .getDcpInitialChannels ();
@@ -228,6 +230,7 @@ public boolean equals(Object o) {
228230 && Objects .equals (this .sessionPoolOptions , other .sessionPoolOptions )
229231 && Objects .equals (this .numChannels , other .numChannels )
230232 && Objects .equals (this .enableDynamicChannelPool , other .enableDynamicChannelPool )
233+ && Objects .equals (this .enableGrpcGcp , other .enableGrpcGcp )
231234 && Objects .equals (this .dcpMinChannels , other .dcpMinChannels )
232235 && Objects .equals (this .dcpMaxChannels , other .dcpMaxChannels )
233236 && Objects .equals (this .dcpInitialChannels , other .dcpInitialChannels )
@@ -258,6 +261,7 @@ public int hashCode() {
258261 this .sessionPoolOptions ,
259262 this .numChannels ,
260263 this .enableDynamicChannelPool ,
264+ this .enableGrpcGcp ,
261265 this .dcpMinChannels ,
262266 this .dcpMaxChannels ,
263267 this .dcpInitialChannels ,
@@ -421,9 +425,18 @@ Spanner createSpanner(SpannerPoolKey key, ConnectionOptions options) {
421425 if (key .numChannels != null ) {
422426 builder .setNumChannels (key .numChannels );
423427 }
428+ if (key .enableGrpcGcp != null ) {
429+ if (Boolean .TRUE .equals (key .enableGrpcGcp )) {
430+ builder .enableGrpcGcpExtension ();
431+ } else {
432+ builder .disableGrpcGcpExtension ();
433+ }
434+ }
424435 // Configure Dynamic Channel Pooling (DCP) based on explicit user setting.
425436 // Note: Setting numChannels disables DCP even if enableDynamicChannelPool is true.
426- if (key .enableDynamicChannelPool != null && key .numChannels == null ) {
437+ if (key .enableDynamicChannelPool != null
438+ && key .numChannels == null
439+ && !Boolean .FALSE .equals (key .enableGrpcGcp )) {
427440 if (Boolean .TRUE .equals (key .enableDynamicChannelPool )) {
428441 builder .enableDynamicChannelPool ();
429442 // Build custom GcpChannelPoolOptions if any DCP-specific options are set.
0 commit comments