File tree 2 files changed +19
-3
lines changed
main/java/com/google/api/gax/rpc
test/java/com/google/api/gax/rpc
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -272,9 +272,6 @@ private String determineUniverseDomain() {
272
272
273
273
/** Determines the fully resolved endpoint and universe domain values */
274
274
private String determineEndpoint () throws IOException {
275
- if (shouldUseS2A ()) {
276
- return mtlsEndpoint ();
277
- }
278
275
MtlsProvider mtlsProvider = mtlsProvider () == null ? new MtlsProvider () : mtlsProvider ();
279
276
// TransportChannelProvider's endpoint will override the ClientSettings' endpoint
280
277
String customEndpoint =
@@ -312,6 +309,11 @@ private String determineEndpoint() throws IOException {
312
309
/** Determine if S2A can be used */
313
310
@ VisibleForTesting
314
311
boolean shouldUseS2A () {
312
+ // If mTLS endpoint is not available, skip S2A
313
+ if (Strings .isNullOrEmpty (mtlsEndpoint ())) {
314
+ return false ;
315
+ }
316
+
315
317
// If EXPERIMENTAL_GOOGLE_API_USE_S2A is not set to true, skip S2A.
316
318
String s2AEnv ;
317
319
s2AEnv = envProvider ().getenv (S2A_ENV_ENABLE_USE_S2A );
Original file line number Diff line number Diff line change @@ -508,6 +508,20 @@ void shouldUseS2A_customEndpointSetViaTransportChannelProvider_returnsFalse() th
508
508
Truth .assertThat (defaultEndpointContextBuilder .shouldUseS2A ()).isFalse ();
509
509
}
510
510
511
+ @ Test
512
+ void shouldUseS2A_mtlsEndpointNull_returnsFalse () throws IOException {
513
+ EnvironmentProvider envProvider = Mockito .mock (EnvironmentProvider .class );
514
+ Mockito .when (envProvider .getenv (EndpointContext .S2A_ENV_ENABLE_USE_S2A )).thenReturn ("true" );
515
+ defaultEndpointContextBuilder =
516
+ defaultEndpointContextBuilder
517
+ .setEnvProvider (envProvider )
518
+ .setClientSettingsEndpoint ("" )
519
+ .setTransportChannelProviderEndpoint ("" )
520
+ .setUsingGDCH (false )
521
+ .setMtlsEndpoint (null );
522
+ Truth .assertThat (defaultEndpointContextBuilder .shouldUseS2A ()).isFalse ();
523
+ }
524
+
511
525
@ Test
512
526
void shouldUseS2A_mtlsEndpointEmpty_returnsFalse () throws IOException {
513
527
EnvironmentProvider envProvider = Mockito .mock (EnvironmentProvider .class );
You can’t perform that action at this time.
0 commit comments