Skip to content

Commit 1397e30

Browse files
committed
fix: use-integer-and-default-environment-refresh-interval-to-60
Signed-off-by: wadii <[email protected]>
1 parent ba277bf commit 1397e30

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithClientConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private static FlagsmithConfig initializeConfig(FlagsmithProviderOptions options
118118
flagsmithConfig.withLocalEvaluation(options.isLocalEvaluation());
119119
}
120120

121-
if (options.getEnvironmentRefreshIntervalSeconds() > -1) {
121+
if (options.getEnvironmentRefreshIntervalSeconds() != null) {
122122
flagsmithConfig.withEnvironmentRefreshIntervalSeconds(options.getEnvironmentRefreshIntervalSeconds());
123123
}
124124

providers/flagsmith/src/main/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderOptions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public class FlagsmithProviderOptions {
118118
* Set environment refresh rate with polling manager. Only needed when local evaluation is true.
119119
* Optional. Default: 60
120120
*/
121-
private int environmentRefreshIntervalSeconds = 60;
121+
@Builder.Default
122+
private Integer environmentRefreshIntervalSeconds = 60;
122123

123124
/**
124125
* Controls whether Flag Analytics data is sent to the Flagsmith API See

providers/flagsmith/src/test/java/dev.openfeature.contrib.providers.flagsmith/FlagsmithProviderTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@ void shouldGetMetadataAndValidateName() {
203203
.getName());
204204
}
205205

206+
@Test
207+
void shouldDefaultEnvironmentRefreshIntervalSecondsTo60() {
208+
FlagsmithProviderOptions options = FlagsmithProviderOptions.builder()
209+
.apiKey("API_KEY")
210+
.localEvaluation(true)
211+
.build();
212+
assertEquals(Integer.valueOf(60), options.getEnvironmentRefreshIntervalSeconds());
213+
}
214+
206215
@ParameterizedTest
207216
@MethodSource("invalidOptions")
208217
void shouldThrowAnExceptionWhenOptionsInvalid(FlagsmithProviderOptions options) {

0 commit comments

Comments
 (0)