From 6cf7387ebfbcde39dc0530358e4ae6ec430616ca Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Wed, 26 Jul 2023 11:08:06 -0400 Subject: [PATCH 1/3] fix: getState mandatory on EventProvider Signed-off-by: Todd Baert --- src/main/java/dev/openfeature/sdk/EventProvider.java | 6 ++++++ src/main/java/dev/openfeature/sdk/FeatureProvider.java | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/openfeature/sdk/EventProvider.java b/src/main/java/dev/openfeature/sdk/EventProvider.java index de12b0777..928b96f41 100644 --- a/src/main/java/dev/openfeature/sdk/EventProvider.java +++ b/src/main/java/dev/openfeature/sdk/EventProvider.java @@ -16,6 +16,12 @@ */ public abstract class EventProvider implements FeatureProvider { + /** + * {@inheritDoc} + */ + @Override + public abstract ProviderState getState(); + private TriConsumer onEmit = null; /** diff --git a/src/main/java/dev/openfeature/sdk/FeatureProvider.java b/src/main/java/dev/openfeature/sdk/FeatureProvider.java index 933166fac..e1e06d0ab 100644 --- a/src/main/java/dev/openfeature/sdk/FeatureProvider.java +++ b/src/main/java/dev/openfeature/sdk/FeatureProvider.java @@ -31,7 +31,7 @@ default List getProviderHooks() { * if they have special initialization needed prior being called for flag * evaluation. *

- * It is ok, if the method is expensive as it is executed in the background. All + * It is ok if the method is expensive as it is executed in the background. All * runtime exceptions will be * caught and logged. *

@@ -46,7 +46,7 @@ default void initialize(EvaluationContext evaluationContext) throws Exception { * Providers can overwrite this method, if they have special shutdown actions * needed. *

- * It is ok, if the method is expensive as it is executed in the background. All + * It is ok if the method is expensive as it is executed in the background. All * runtime exceptions will be * caught and logged. *

@@ -57,7 +57,11 @@ default void shutdown() { /** * Returns a representation of the current readiness of the provider. - * Providers which do not implement this method are assumed to be ready immediately. + * If the provider needs to be initialized, it should return {@link ProviderState#NOT_READY}. + * If the provider is in an error state, it should return {@link ProviderState#ERROR}. + * If the provider is functioning normally, it should return {@link ProviderState#READY}. + * + *

Providers which do not implement this method are assumed to be ready immediately.

* * @return ProviderState */ From c2c4e878a108cd3c862f383cc2e4a249c152a7fa Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Wed, 26 Jul 2023 11:20:24 -0400 Subject: [PATCH 2/3] fixup: update test class Signed-off-by: Todd Baert --- src/test/java/dev/openfeature/sdk/EventProviderTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/dev/openfeature/sdk/EventProviderTest.java b/src/test/java/dev/openfeature/sdk/EventProviderTest.java index cb73b5292..83f6a1565 100644 --- a/src/test/java/dev/openfeature/sdk/EventProviderTest.java +++ b/src/test/java/dev/openfeature/sdk/EventProviderTest.java @@ -121,6 +121,11 @@ public ProviderEvaluation getObjectEvaluation(String key, Value defaultVa // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getObjectEvaluation'"); } + + @Override + public ProviderState getState() { + return ProviderState.READY; + } } @SuppressWarnings("unchecked") From 527c9f768af523e75ae89b212263954ad06d7042 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Thu, 27 Jul 2023 08:18:13 -0400 Subject: [PATCH 3/3] Update src/test/java/dev/openfeature/sdk/EventProviderTest.java Co-authored-by: Giovanni Liva Signed-off-by: Todd Baert --- src/test/java/dev/openfeature/sdk/EventProviderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/dev/openfeature/sdk/EventProviderTest.java b/src/test/java/dev/openfeature/sdk/EventProviderTest.java index 83f6a1565..3744682b9 100644 --- a/src/test/java/dev/openfeature/sdk/EventProviderTest.java +++ b/src/test/java/dev/openfeature/sdk/EventProviderTest.java @@ -124,7 +124,7 @@ public ProviderEvaluation getObjectEvaluation(String key, Value defaultVa @Override public ProviderState getState() { - return ProviderState.READY; + return ProviderState.READY; } }