Skip to content

Commit 0bf62f6

Browse files
committed
reviews
1 parent 5ba5226 commit 0bf62f6

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static ResilienceConfiguration createResilienceConfiguration(
122122
{
123123
if( Cache.preLookupCheckEnabled && !preLookupCheckSuccessful(destinationName) ) {
124124
final String msg = "Destination %s was not found among the destinations of the current tenant.";
125-
return Try.failure(new DestinationAccessException(String.format(msg, destinationName)));
125+
return Try.failure(new DestinationNotFoundException(String.format(msg, destinationName)));
126126
}
127127
return Cache.getOrComputeDestination(this, destinationName, options, this::loadAndParseDestination);
128128
}
@@ -455,17 +455,6 @@ static boolean isChangeDetectionEnabled()
455455
return changeDetectionEnabled;
456456
}
457457

458-
/**
459-
* Enables checking if a destination exists before trying to call it directly when invoking
460-
* {@link #tryGetDestination}.
461-
*
462-
* @since 5.25.0
463-
*/
464-
public static void enablePreLookupCheck()
465-
{
466-
preLookupCheckEnabled = true;
467-
}
468-
469458
/**
470459
* Disables checking if a destination exists before trying to call it directly when invoking
471460
* {@link #tryGetDestination}.

cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,15 +1926,16 @@ private String createHttpDestinationServiceResponse( final String name, final St
19261926
@Test
19271927
void testPrependGetAllDestinationsCall()
19281928
{
1929+
// Reset Cache to re-enable the PreLookupCheck
1930+
DestinationService.Cache.reset();
1931+
19291932
doReturn(responseServiceInstanceDestination)
19301933
.when(destinationServiceAdapter)
19311934
.getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
19321935
doReturn(responseSubaccountDestination)
19331936
.when(destinationServiceAdapter)
19341937
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
19351938

1936-
DestinationService.Cache.enablePreLookupCheck();
1937-
19381939
Destination result = loader.tryGetDestination(destinationName).get();
19391940

19401941
verify(destinationServiceAdapter, times(1)).getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
@@ -1947,17 +1948,18 @@ void testPrependGetAllDestinationsCall()
19471948
@Test
19481949
void testPrependGetAllDestinationsCallWithMissingDestination()
19491950
{
1951+
// Reset Cache to re-enable the PreLookupCheck
1952+
DestinationService.Cache.reset();
1953+
19501954
doReturn(responseServiceInstanceDestination)
19511955
.when(destinationServiceAdapter)
19521956
.getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
19531957
doReturn(responseSubaccountDestination)
19541958
.when(destinationServiceAdapter)
19551959
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
19561960

1957-
DestinationService.Cache.enablePreLookupCheck();
1958-
19591961
assertThatThrownBy(() -> loader.tryGetDestination("thisDestinationDoesNotExist").get())
1960-
.isInstanceOf(DestinationAccessException.class)
1962+
.isInstanceOf(DestinationNotFoundException.class)
19611963
.hasMessageContaining("was not found among the destinations of the current tenant.");
19621964

19631965
verify(destinationServiceAdapter, times(1)).getConfigurationAsJson(eq("/v1/instanceDestinations"), any());

0 commit comments

Comments
 (0)