diff --git a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java index 2d91b987c..7e66c00bd 100644 --- a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java +++ b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java @@ -120,7 +120,7 @@ static ResilienceConfiguration createResilienceConfiguration( Try tryGetDestination( @Nonnull final String destinationName, @Nonnull final DestinationOptions options ) { - if( Cache.preLookupCheckEnabled && !preLookupCheckSuccessful(destinationName) ) { + if( Cache.preLookupCheckEnabled && !preLookupCheckSuccessful(destinationName, options) ) { final String msg = "Destination %s was not found among the destinations of the current tenant."; return Try.failure(new DestinationNotFoundException(String.format(msg, destinationName))); } @@ -388,9 +388,9 @@ private static boolean hasCauseAssignableFrom( @Nonnull final Throwable t, @Nonn return ExceptionUtils.getThrowableList(t).stream().map(Throwable::getClass).anyMatch(cls::isAssignableFrom); } - private boolean preLookupCheckSuccessful( final String destinationName ) + private boolean preLookupCheckSuccessful( final String destinationName, final DestinationOptions options ) { - return getAllDestinationProperties() + return getAllDestinationProperties(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options).get()) .stream() .anyMatch(properties -> properties.get(DestinationProperty.NAME).contains(destinationName)); } diff --git a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeAllDestinationsCommand.java b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeAllDestinationsCommand.java index ac9c217d2..bef1257ad 100644 --- a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeAllDestinationsCommand.java +++ b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeAllDestinationsCommand.java @@ -41,7 +41,7 @@ static GetOrComputeAllDestinationsCommand prepareCommand( final CacheKey cacheKey = CacheKey.ofTenantOptionalIsolation(); - cacheKey.append(destinationOptions); + cacheKey.append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(destinationOptions)); final ReentrantLock isolationLock = Objects.requireNonNull(isolationLocks.get(cacheKey, any -> new ReentrantLock())); diff --git a/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceTest.java b/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceTest.java index 7bb4bb669..bafee51c5 100644 --- a/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceTest.java +++ b/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceTest.java @@ -1267,9 +1267,13 @@ void testConcurrentFetchSameDestinationButDifferentTenant() assertThat(DestinationService.Cache.isolationLocks().asMap()) .containsOnlyKeys( CacheKey.fromIds("TenantA", null).append(destinationName, options), - CacheKey.fromIds("TenantA", null).append(options), + CacheKey + .fromIds("TenantA", null) + .append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options)), CacheKey.fromIds("TenantB", null).append(destinationName, options), - CacheKey.fromIds("TenantB", null).append(options)); + CacheKey + .fromIds("TenantB", null) + .append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options))); // assert cache entries for one get-single command for each tenant assertThat(DestinationService.Cache.instanceSingle().asMap()) @@ -1339,7 +1343,9 @@ void testPrincipalIsolationForDestinationWithUserPropagationWithExchangeOnlyStra .containsOnlyKeys( CacheKey.of(subscriberTenant, principal1).append(destinationName, options), CacheKey.of(subscriberTenant, principal2).append(destinationName, options), - CacheKey.of(subscriberTenant, null).append(options)); + CacheKey + .of(subscriberTenant, null) + .append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options))); assertThat(DestinationService.Cache.instanceSingle().asMap()) .containsOnlyKeys( @@ -1383,7 +1389,9 @@ void testPrincipalIsolationForDestinationWithUserPropagationWithDefaultExchangeS assertThat(DestinationService.Cache.isolationLocks().asMap()) .containsOnlyKeys( CacheKey.of(subscriberTenant, null).append(destinationName, options), - CacheKey.of(subscriberTenant, null).append(options)); + CacheKey + .of(subscriberTenant, null) + .append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options))); assertThat(DestinationService.Cache.instanceSingle().asMap()) .containsOnlyKeys( diff --git a/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeAllDestinationsCommandTest.java b/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeAllDestinationsCommandTest.java index afbd3cc98..a66528fb0 100644 --- a/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeAllDestinationsCommandTest.java +++ b/cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeAllDestinationsCommandTest.java @@ -90,7 +90,12 @@ void testCommandIsIdempotent() assertThat(result.get()).containsExactly(destination); assertThat(allDestinationsCache.estimatedSize()).isEqualTo(1); - assertThat(allDestinationsCache.getIfPresent(CacheKey.ofNoIsolation().append(EMPTY_OPTIONS))) + assertThat( + allDestinationsCache + .getIfPresent( + CacheKey + .ofNoIsolation() + .append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(EMPTY_OPTIONS)))) .containsExactly(destination); verify(tryGetAllDestinations, times(1)).get(); } @@ -104,8 +109,10 @@ void testIsolationAndAtomicityPerTenant() final CountDownLatch mainThreadLatch = new CountDownLatch(1); final CountDownLatch getAllLatch = new CountDownLatch(1); final AtomicInteger lockInvocations = new AtomicInteger(); - final CacheKey t1Key = CacheKey.of(t1, null).append(EMPTY_OPTIONS); - final CacheKey t2Key = CacheKey.of(t2, null).append(EMPTY_OPTIONS); + final CacheKey t1Key = + CacheKey.of(t1, null).append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(EMPTY_OPTIONS)); + final CacheKey t2Key = + CacheKey.of(t2, null).append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(EMPTY_OPTIONS)); final ReentrantLock tenantIsolationLock = spy(ReentrantLock.class); doAnswer(invocation -> {