diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml
index 51d62680..4e705114 100644
--- a/.github/workflows/pullrequest.yml
+++ b/.github/workflows/pullrequest.yml
@@ -27,7 +27,7 @@ jobs:
cache: maven
- name: Initialize CodeQL
- uses: github/codeql-action/init@9e4932e2919d7a061a0cb982d1f9d841120ea6df
+ uses: github/codeql-action/init@2160dd3b55fb3a72bfc85e989cad8aa785d2e8d5
with:
languages: java
@@ -52,4 +52,4 @@ jobs:
verbose: true # optional (default = false)
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@9e4932e2919d7a061a0cb982d1f9d841120ea6df
+ uses: github/codeql-action/analyze@2160dd3b55fb3a72bfc85e989cad8aa785d2e8d5
diff --git a/.github/workflows/static-code-scanning.yaml b/.github/workflows/static-code-scanning.yaml
index a6f3761f..00f33d2b 100644
--- a/.github/workflows/static-code-scanning.yaml
+++ b/.github/workflows/static-code-scanning.yaml
@@ -33,12 +33,12 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@9e4932e2919d7a061a0cb982d1f9d841120ea6df
+ uses: github/codeql-action/init@2160dd3b55fb3a72bfc85e989cad8aa785d2e8d5
with:
languages: java
- name: Autobuild
- uses: github/codeql-action/autobuild@9e4932e2919d7a061a0cb982d1f9d841120ea6df
+ uses: github/codeql-action/autobuild@2160dd3b55fb3a72bfc85e989cad8aa785d2e8d5
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@9e4932e2919d7a061a0cb982d1f9d841120ea6df
+ uses: github/codeql-action/analyze@2160dd3b55fb3a72bfc85e989cad8aa785d2e8d5
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 9b090798..54824065 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1 +1 @@
-{".":"1.4.2"}
\ No newline at end of file
+{".":"1.4.3"}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c5d0238b..0ed96d88 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog
+## [1.4.3](https://github.com/open-feature/java-sdk/compare/v1.4.2...v1.4.3) (2023-08-11)
+
+
+### ๐ Bug Fixes
+
+* ability to set provider after shutdown ([#556](https://github.com/open-feature/java-sdk/issues/556)) ([fb42a92](https://github.com/open-feature/java-sdk/commit/fb42a92e9b36e57ba71bc05a4f52eda88729f21e))
+
+
+### ๐งน Chore
+
+* **deps:** update github/codeql-action digest to 2160dd3 ([#555](https://github.com/open-feature/java-sdk/issues/555)) ([a6eabc3](https://github.com/open-feature/java-sdk/commit/a6eabc391de27b9dff16310d942abff8675b924e))
+* **deps:** update github/codeql-action digest to 2ec74e3 ([#553](https://github.com/open-feature/java-sdk/issues/553)) ([d8c64d9](https://github.com/open-feature/java-sdk/commit/d8c64d91c43b62af383c1ae6e09417da480c92d2))
+
## [1.4.2](https://github.com/open-feature/java-sdk/compare/v1.4.1...v1.4.2) (2023-08-10)
diff --git a/README.md b/README.md
index 3a48562a..b453b426 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ Note that this library is intended to be used in server-side contexts and has no
dev.openfeature
sdk
- 1.4.2
+ 1.4.3
```
@@ -67,7 +67,7 @@ If you would like snapshot builds, this is the relevant repository information:
```groovy
dependencies {
- implementation 'dev.openfeature:sdk:1.4.2'
+ implementation 'dev.openfeature:sdk:1.4.3'
}
```
diff --git a/pom.xml b/pom.xml
index 79d142df..098d6eb0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
dev.openfeature
sdk
- 1.4.2
+ 1.4.3
UTF-8
diff --git a/src/main/java/dev/openfeature/sdk/EventSupport.java b/src/main/java/dev/openfeature/sdk/EventSupport.java
index 3a55f298..7620c3f8 100644
--- a/src/main/java/dev/openfeature/sdk/EventSupport.java
+++ b/src/main/java/dev/openfeature/sdk/EventSupport.java
@@ -145,7 +145,11 @@ public void runHandler(Consumer handler, EventDetails eventDetails
* Stop the event handler task executor.
*/
public void shutdown() {
- taskExecutor.shutdown();
+ try {
+ taskExecutor.shutdown();
+ } catch (Exception e) {
+ log.warn("Exception while attempting to shutdown task executor", e);
+ }
}
// Handler store maintains a set of handlers for each event type.
diff --git a/src/main/java/dev/openfeature/sdk/OpenFeatureAPI.java b/src/main/java/dev/openfeature/sdk/OpenFeatureAPI.java
index 42ff4708..94047b8c 100644
--- a/src/main/java/dev/openfeature/sdk/OpenFeatureAPI.java
+++ b/src/main/java/dev/openfeature/sdk/OpenFeatureAPI.java
@@ -21,13 +21,15 @@
public class OpenFeatureAPI implements EventBus {
// package-private multi-read/single-write lock
static AutoCloseableReentrantReadWriteLock lock = new AutoCloseableReentrantReadWriteLock();
- private EvaluationContext evaluationContext;
private final List apiHooks;
- private ProviderRepository providerRepository = new ProviderRepository();
- private EventSupport eventSupport = new EventSupport();
+ private ProviderRepository providerRepository;
+ private EventSupport eventSupport;
+ private EvaluationContext evaluationContext;
protected OpenFeatureAPI() {
apiHooks = new ArrayList<>();
+ providerRepository = new ProviderRepository();
+ eventSupport = new EventSupport();
}
private static class SingletonHolder {
@@ -190,9 +192,19 @@ public void clearHooks() {
}
}
+ /**
+ * Shut down and reset the current status of OpenFeature API.
+ * This call cleans up all active providers and attempts to shut down internal event handling mechanisms.
+ * Once shut down is complete, API is reset and ready to use again.
+ * */
public void shutdown() {
- providerRepository.shutdown();
- eventSupport.shutdown();
+ try (AutoCloseableLock __ = lock.writeLockAutoCloseable()) {
+ providerRepository.shutdown();
+ eventSupport.shutdown();
+
+ providerRepository = new ProviderRepository();
+ eventSupport = new EventSupport();
+ }
}
/**
@@ -264,15 +276,6 @@ void addHandler(String clientName, ProviderEvent event, Consumer h
}
}
- /**
- * This method is only here for testing as otherwise all tests after the API
- * shutdown test would fail.
- */
- final void reset() {
- providerRepository = new ProviderRepository();
- eventSupport = new EventSupport();
- }
-
/**
* Runs the handlers associated with a particular provider.
*
diff --git a/src/test/java/dev/openfeature/sdk/ShutdownBehaviorSpecTest.java b/src/test/java/dev/openfeature/sdk/ShutdownBehaviorSpecTest.java
index e470819f..8659ce78 100644
--- a/src/test/java/dev/openfeature/sdk/ShutdownBehaviorSpecTest.java
+++ b/src/test/java/dev/openfeature/sdk/ShutdownBehaviorSpecTest.java
@@ -109,9 +109,22 @@ void mustShutdownAllProvidersOnShuttingDownApi() {
verify(defaultProvider).shutdown();
verify(namedProvider).shutdown();
});
-
- api.reset();
}
}
+
+
+ @Test
+ @DisplayName("once shutdown is complete, api must be ready to use again")
+ void apiIsReadyToUseAfterShutdown() {
+ final OpenFeatureAPI openFeatureAPI = OpenFeatureAPI.getInstance();
+
+ NoOpProvider p1 = new NoOpProvider();
+ openFeatureAPI.setProvider(p1);
+
+ openFeatureAPI.shutdown();
+
+ NoOpProvider p2 = new NoOpProvider();
+ openFeatureAPI.setProvider(p2);
+ }
}
}
diff --git a/version.txt b/version.txt
index 9df886c4..428b770e 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-1.4.2
+1.4.3