Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/com/configcat/ConfigService.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public ConfigService(String sdkKey,

} else {
// Sync up with cache before reporting ready state
cachedEntry.set(readCache());
Entry fromCache = readCache();
if (!fromCache.isEmpty() && !fromCache.getETag().equals(cachedEntry.get().getETag())){
cachedEntry.set(fromCache);
configCatHooks.invokeOnConfigChanged(fromCache.getConfig().getEntries());
}
setInitialized();
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/com/configcat/ConfigCatClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -910,14 +910,18 @@ void testHooksSub() throws IOException {
void testReadyHookManualPollWithCache() throws IOException {

AtomicReference<ClientCacheState> ready = new AtomicReference<>(null);
AtomicBoolean changed = new AtomicBoolean(false);

ConfigCache cache = new SingleValueCache(Helpers.cacheValueFromConfigJson(String.format(TEST_JSON, "test")));

ConfigCatClient cl = ConfigCatClient.get(Helpers.SDK_KEY, options -> {
options.pollingMode(PollingModes.manualPoll());
options.cache(cache);
options.hooks().addOnConfigChanged(map -> changed.set(true));
options.hooks().addOnClientReady(ready::set);
});

assertTrue(changed.get());
assertEquals(ClientCacheState.HAS_CACHED_FLAG_DATA_ONLY, ready.get());

cl.close();
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/configcat/UserAttributeConvertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ private static Stream<Arguments> testDataForUserTest() {
//String Array data
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, new String[]{"x", "read"}, "Dog"),
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, new String[]{"x", "Read"}, "Cat"),
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, new String[]{"x", "read", null}, "Cat"),
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, Arrays.asList("x", "read"), "Dog"),
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, Arrays.asList("x", "Read"), "Cat"),
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, Arrays.asList("x", "read", null), "Cat"),
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, "[\"x\", \"read\"]", "Dog"),
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, "[\"x\", \"Read\"]", "Cat"),
Arguments.of("configcat-sdk-1/JcPbCGl_1E-K9M-fJOyKyQ/OfQqcTjfFUGBwMKqtyEOrQ", "stringArrayContainsAnyOfDogDefaultCat", String.class, "x, read", "Cat"),
Expand Down
Loading