This is an automated email from the ASF dual-hosted git repository.
jayblanc pushed a commit to branch make-healthcheck-concurrent
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/make-healthcheck-concurrent by
this push:
new 7f828d853 feat: improve refresh conditions
7f828d853 is described below
commit 7f828d8534bef69f4b8316e500be0d3fa26a2ef3
Author: Jérôme Blanchard <[email protected]>
AuthorDate: Tue Dec 23 17:56:03 2025 +0100
feat: improve refresh conditions
---
.../unomi/healthcheck/HealthCheckService.java | 24 ++++++++++------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git
a/extensions/healthcheck/src/main/java/org/apache/unomi/healthcheck/HealthCheckService.java
b/extensions/healthcheck/src/main/java/org/apache/unomi/healthcheck/HealthCheckService.java
index f7da22e85..41bdb9135 100644
---
a/extensions/healthcheck/src/main/java/org/apache/unomi/healthcheck/HealthCheckService.java
+++
b/extensions/healthcheck/src/main/java/org/apache/unomi/healthcheck/HealthCheckService.java
@@ -130,18 +130,16 @@ public class HealthCheckService {
}
}
} else if (shouldRefreshCache()) {
- if (!busy) {
- synchronized (cacheLock) {
- if (!busy) {
- busy = true;
- executor.submit(() -> {
- try {
- refreshCacheSync();
- } finally {
- busy = false;
- }
- });
- }
+ synchronized (cacheLock) {
+ if (!busy) {
+ busy = true;
+ executor.submit(() -> {
+ try {
+ refreshCacheSync();
+ } finally {
+ busy = false;
+ }
+ });
}
}
}
@@ -149,7 +147,7 @@ public class HealthCheckService {
}
private boolean shouldRefreshCache() {
- return healthCache.isEmpty() || (System.currentTimeMillis() -
cacheTimestamp) > 1000;
+ return !busy && (System.currentTimeMillis() - cacheTimestamp) > 1000;
}
private void refreshCacheSync() {