diff --git a/eppo/src/main/java/cloud/eppo/android/ConfigurationRequestor.java b/eppo/src/main/java/cloud/eppo/android/ConfigurationRequestor.java index 41753ee0..c30a41cb 100644 --- a/eppo/src/main/java/cloud/eppo/android/ConfigurationRequestor.java +++ b/eppo/src/main/java/cloud/eppo/android/ConfigurationRequestor.java @@ -25,10 +25,11 @@ public ConfigurationRequestor(ConfigurationStore configurationStore, EppoHttpCli } public void load(InitializationCallback callback) { - // We have two at-bats to load the configuration; track their success - AtomicBoolean cacheLoadInProgress = new AtomicBoolean(false); + // We have two at-bats to load the configuration: loading from cache and fetching + // The below variables help them keep track of each other's progress + AtomicBoolean cacheLoadInProgress = new AtomicBoolean(true); AtomicReference fetchErrorMessage = new AtomicReference<>(null); - // We only want to fire the callback off once; track whether or not we have yet + // We only want to fire the callback off once; so track whether or not we have yet AtomicBoolean callbackCalled = new AtomicBoolean(false); configurationStore.loadFromCache(new CacheLoadCallback() { @Override @@ -61,7 +62,7 @@ public void onSuccess(Reader response) { } catch (JsonSyntaxException | JsonIOException e) { fetchErrorMessage.set(e.getMessage()); Log.e(TAG, "Error loading configuration response", e); - // If cache loading in progress, defer to it's outcome for firing the success or failure callback + // Below includes a check for cache loading in progress, as if so, we'll defer to it's outcome for firing the success or failure callback if (callback != null && !cacheLoadInProgress.get() && callbackCalled.compareAndSet(false, true)) { Log.d(TAG, "Failed to initialize from cache or by fetching"); callback.onError("Cache and fetch failed "+e.getMessage()); diff --git a/eppo/src/main/java/cloud/eppo/android/RuleEvaluator.java b/eppo/src/main/java/cloud/eppo/android/RuleEvaluator.java index 5fdf4a5a..10471819 100644 --- a/eppo/src/main/java/cloud/eppo/android/RuleEvaluator.java +++ b/eppo/src/main/java/cloud/eppo/android/RuleEvaluator.java @@ -201,5 +201,4 @@ private static String castAttributeForListComparison(EppoValue attributeValue) { throw new IllegalArgumentException("Unknown EppoValue type for casting for list comparison: "+attributeValue); } } - } \ No newline at end of file diff --git a/eppo/src/main/java/cloud/eppo/android/dto/OperatorType.java b/eppo/src/main/java/cloud/eppo/android/dto/OperatorType.java index 05554152..89aa03cc 100644 --- a/eppo/src/main/java/cloud/eppo/android/dto/OperatorType.java +++ b/eppo/src/main/java/cloud/eppo/android/dto/OperatorType.java @@ -23,7 +23,7 @@ public static OperatorType fromString(String value) { if (type.value.equals(value) || getMD5Hex(type.value).equals(value) || getMD5Hex(type.value).equals(value) - // gson deserializes enums using their names so check it to in case we are reading from cache + // gson deserializes enums using their names so check that too in case we are reading from cache || type.name().equals(value) || getMD5Hex(type.name()).equals(value) ) { diff --git a/eppo/src/main/java/cloud/eppo/android/dto/adapters/DateAdapter.java b/eppo/src/main/java/cloud/eppo/android/dto/adapters/DateAdapter.java index 74d3d8c3..fcf1608e 100644 --- a/eppo/src/main/java/cloud/eppo/android/dto/adapters/DateAdapter.java +++ b/eppo/src/main/java/cloud/eppo/android/dto/adapters/DateAdapter.java @@ -10,6 +10,9 @@ import java.lang.reflect.Type; import java.util.Date; +/** + * This adapter for Date allows gson to serialize to UTC ISO 8601 (vs. its default of local timezone) + */ public class DateAdapter implements JsonSerializer { @Override diff --git a/eppo/src/test/java/cloud/eppo/android/FlagEvaluatorTest.java b/eppo/src/test/java/cloud/eppo/android/FlagEvaluatorTest.java index 6002b15a..08231a54 100644 --- a/eppo/src/test/java/cloud/eppo/android/FlagEvaluatorTest.java +++ b/eppo/src/test/java/cloud/eppo/android/FlagEvaluatorTest.java @@ -360,6 +360,7 @@ public void testAllocationStartAndEndAt() { public void testObfuscated() { // Note: this is NOT a comprehensive test of obfuscation (many operators and value types are // excluded, as are startAt and endAt) + // Much more is covered by EppoClientTest Map variations = createVariations("a", "b"); List firstAllocationSplits = createSplits("b");