Skip to content

Commit 2501904

Browse files
committed
move feature switch
1 parent 5475777 commit 2501904

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ public class DestinationService implements DestinationLoader
8080
@Getter( AccessLevel.PACKAGE )
8181
private final ResilienceConfiguration allDestResilience;
8282

83-
@Nonnull
84-
@Setter
85-
private Boolean prependGetAllDestinationCall = false;
86-
8783
/**
8884
* Create instance with all default settings
8985
*/
@@ -130,8 +126,7 @@ static ResilienceConfiguration createResilienceConfiguration(
130126
this,
131127
destinationName,
132128
options,
133-
this::loadAndParseDestination,
134-
prependGetAllDestinationCall);
129+
this::loadAndParseDestination);
135130
}
136131

137132
Destination loadAndParseDestination( final String destName, final DestinationOptions options )
@@ -437,6 +432,8 @@ public static final class Cache
437432

438433
private static boolean cacheEnabled = true;
439434
private static boolean changeDetectionEnabled = true;
435+
private static boolean getAllDocumentsPrepended = false;
436+
// JONAS: put feature switch here
440437

441438
static {
442439
recreateSingleCache();
@@ -454,6 +451,14 @@ static boolean isChangeDetectionEnabled()
454451
return changeDetectionEnabled;
455452
}
456453

454+
static boolean isGetAllDocumentsPrepended() {
455+
return getAllDocumentsPrepended;
456+
}
457+
458+
public static void setGetAllDocumentsPrepended(boolean bool) {
459+
getAllDocumentsPrepended = bool;
460+
}
461+
457462
@Nonnull
458463
static com.github.benmanes.caffeine.cache.Cache<CacheKey, Destination> instanceSingle()
459464
{
@@ -507,6 +512,7 @@ static void reset()
507512
cacheEnabled = true;
508513
}
509514
changeDetectionEnabled = true;
515+
getAllDocumentsPrepended = false;
510516

511517
sizeLimit = Option.some(DEFAULT_SIZE_LIMIT);
512518
expirationDuration = Option.some(DEFAULT_EXPIRATION_DURATION);
@@ -850,8 +856,7 @@ private static Try<Destination> getOrComputeDestination(
850856
@Nonnull final DestinationService loader,
851857
@Nonnull final String destinationName,
852858
@Nonnull final DestinationOptions options,
853-
@Nonnull final BiFunction<String, DestinationOptions, Destination> destinationDownloader,
854-
@Nonnull final Boolean prependGetAllCall )
859+
@Nonnull final BiFunction<String, DestinationOptions, Destination> destinationDownloader)
855860
{
856861
if( !cacheEnabled ) {
857862
return Try.ofSupplier(() -> destinationDownloader.apply(destinationName, options));
@@ -879,7 +884,7 @@ private static Try<Destination> getOrComputeDestination(
879884
isolationLocks(),
880885
destinationDownloader,
881886
getAllCommand,
882-
prependGetAllCall);
887+
getAllDocumentsPrepended);
883888
return command.flatMap(GetOrComputeSingleDestinationCommand::execute);
884889
}
885890

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,8 @@ void testPrependGetAllDestinationsCall()
19301930
.when(destinationServiceAdapter)
19311931
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
19321932

1933-
loader.setPrependGetAllDestinationCall(true);
1933+
DestinationService.Cache.setGetAllDocumentsPrepended(true);
1934+
19341935

19351936
final DestinationOptions options =
19361937
DestinationOptions.builder().augmentBuilder(augmenter().retrievalStrategy(ALWAYS_PROVIDER)).build();
@@ -1943,7 +1944,7 @@ void testPrependGetAllDestinationsCall()
19431944
.getConfigurationAsJson(eq("/v1/destinations/" + destinationName), any());
19441945
verifyNoMoreInteractions(destinationServiceAdapter);
19451946

1946-
loader.setPrependGetAllDestinationCall(false);
1947+
DestinationService.Cache.setGetAllDocumentsPrepended(false);
19471948
}
19481949

19491950
@Test
@@ -1956,7 +1957,7 @@ void testPrependGetAllDestinationsCallWithMissingDestination()
19561957
.when(destinationServiceAdapter)
19571958
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
19581959

1959-
loader.setPrependGetAllDestinationCall(true);
1960+
DestinationService.Cache.setGetAllDocumentsPrepended(true);
19601961

19611962
final DestinationOptions options =
19621963
DestinationOptions.builder().augmentBuilder(augmenter().retrievalStrategy(ALWAYS_PROVIDER)).build();
@@ -1969,6 +1970,6 @@ void testPrependGetAllDestinationsCallWithMissingDestination()
19691970
verify(destinationServiceAdapter, times(1)).getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
19701971
verifyNoMoreInteractions(destinationServiceAdapter);
19711972

1972-
loader.setPrependGetAllDestinationCall(false);
1973+
DestinationService.Cache.setGetAllDocumentsPrepended(false);
19731974
}
19741975
}

0 commit comments

Comments
 (0)