Skip to content

Commit 4fa2c70

Browse files
committed
fix: ensures graceful provider shutdown
Signed-off-by: Rahul Baradol <rahul.baradol.14@gmail.com>
1 parent b502c6e commit 4fa2c70

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

providers/ofrep/src/main/java/dev/openfeature/contrib/providers/ofrep/OfrepProvider.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,19 @@ public Metadata getMetadata() {
9090
@Override
9191
public void shutdown() {
9292
if (executor instanceof ExecutorService) {
93+
ExecutorService executorService = (ExecutorService) executor;
9394
try {
94-
ExecutorService executorService = (ExecutorService) executor;
95-
executorService.shutdownNow();
96-
executorService.awaitTermination(DEFAULT_EXECUTOR_SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS);
95+
executorService.shutdown();
96+
97+
if (!executorService.awaitTermination(DEFAULT_EXECUTOR_SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) {
98+
executorService.shutdownNow();
99+
if (!executorService.awaitTermination(DEFAULT_EXECUTOR_SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) {
100+
log.error("Provider couldn't shutdown gracefully.");
101+
}
102+
}
97103
} catch (InterruptedException e) {
98-
log.error("Error during shutdown {}", OFREP_PROVIDER, e);
104+
executorService.shutdownNow();
105+
Thread.currentThread().interrupt();
99106
}
100107
}
101108
}

0 commit comments

Comments
 (0)