diff --git a/providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithClientConfigurer.java b/providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithClientConfigurer.java index 66c6d06f5..d6a0005b3 100644 --- a/providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithClientConfigurer.java +++ b/providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithClientConfigurer.java @@ -2,6 +2,7 @@ import com.flagsmith.FlagsmithClient; import com.flagsmith.config.FlagsmithCacheConfig; +import com.flagsmith.config.FlagsmithConfig; import com.flagsmith.config.Retry; import dev.openfeature.contrib.providers.flagsmith.exceptions.InvalidCacheOptionsException; import dev.openfeature.contrib.providers.flagsmith.exceptions.InvalidOptionsException; @@ -35,7 +36,7 @@ static FlagsmithClient initializeProvider(FlagsmithProviderOptions options) { flagsmithBuilder.withCache(flagsmithCacheConfig); } - com.flagsmith.config.FlagsmithConfig flagsmithConfig = initializeConfig(options); + final FlagsmithConfig flagsmithConfig = initializeConfig(options); flagsmithBuilder.withConfiguration(flagsmithConfig); return flagsmithBuilder.build(); @@ -88,10 +89,8 @@ private static FlagsmithCacheConfig initializeCacheConfig(FlagsmithProviderOptio * @param options The options used to create the provider * @return a FlagsmithConfig object with the FlagsmithClient settings */ - private static com.flagsmith.config.FlagsmithConfig initializeConfig( - FlagsmithProviderOptions options) { - com.flagsmith.config.FlagsmithConfig.Builder flagsmithConfig = com.flagsmith.config.FlagsmithConfig - .newBuilder(); + private static FlagsmithConfig initializeConfig(FlagsmithProviderOptions options) { + FlagsmithConfig.Builder flagsmithConfig = FlagsmithConfig.newBuilder(); // Set client level configuration settings if (options.getBaseUri() != null) { @@ -136,6 +135,10 @@ private static com.flagsmith.config.FlagsmithConfig initializeConfig( flagsmithConfig.withEnableAnalytics(options.isEnableAnalytics()); } + if (options.getSupportedProtocols() != null && !options.getSupportedProtocols().isEmpty()) { + flagsmithConfig.withSupportedProtocols(options.getSupportedProtocols()); + } + return flagsmithConfig.build(); } diff --git a/providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderOptions.java b/providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderOptions.java index 623884ce4..57ce4ef73 100644 --- a/providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderOptions.java +++ b/providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderOptions.java @@ -2,8 +2,13 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import com.flagsmith.config.FlagsmithConfig.Protocol; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + import lombok.Builder; import lombok.Getter; import javax.net.ssl.SSLSocketFactory; @@ -183,4 +188,12 @@ public class FlagsmithProviderOptions { */ @Builder.Default private boolean usingBooleanConfigValue = false; + + /** + * Set the list of supported protocols that should be used. + * Optional. + * Default: All the enum protocols from FlagsmithConfig. + */ + @Builder.Default + private List supportedProtocols = Arrays.stream(Protocol.values()).collect(Collectors.toList()); } \ No newline at end of file diff --git a/providers/flagsmith/src/test/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderTest.java b/providers/flagsmith/src/test/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderTest.java index ddeee839e..74ab12d9c 100644 --- a/providers/flagsmith/src/test/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderTest.java +++ b/providers/flagsmith/src/test/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.flagsmith.config.FlagsmithConfig; import dev.openfeature.contrib.providers.flagsmith.exceptions.InvalidCacheOptionsException; import dev.openfeature.contrib.providers.flagsmith.exceptions.InvalidOptionsException; import dev.openfeature.sdk.EvaluationContext; @@ -16,6 +17,8 @@ import java.lang.reflect.Method; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -191,6 +194,7 @@ void shouldInitializeProviderWhenAllOptionsSet() { .environmentRefreshIntervalSeconds(1) .enableAnalytics(true) .usingBooleanConfigValue(false) + .supportedProtocols(Collections.singletonList(FlagsmithConfig.Protocol.HTTP_1_1)) .build(); assertDoesNotThrow(() -> new FlagsmithProvider(options)); }