From 12c80d23ffdca1cdbd2125173a344e8ba9c96724 Mon Sep 17 00:00:00 2001 From: Jitendra Dhawan Date: Wed, 19 Jun 2024 10:52:04 +0530 Subject: [PATCH] if existing node list is empty and fetch node list is empty, refresh service registry --- .../serviceregistry/ServiceRegistryUpdater.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ranger-core/src/main/java/io/appform/ranger/core/finder/serviceregistry/ServiceRegistryUpdater.java b/ranger-core/src/main/java/io/appform/ranger/core/finder/serviceregistry/ServiceRegistryUpdater.java index 63756741..e7ea68b1 100644 --- a/ranger-core/src/main/java/io/appform/ranger/core/finder/serviceregistry/ServiceRegistryUpdater.java +++ b/ranger-core/src/main/java/io/appform/ranger/core/finder/serviceregistry/ServiceRegistryUpdater.java @@ -23,6 +23,8 @@ import io.appform.ranger.core.model.ServiceRegistry; import io.appform.ranger.core.signals.Signal; import io.appform.ranger.core.util.Exceptions; +import java.util.Collections; +import java.util.Objects; import lombok.extern.slf4j.Slf4j; import lombok.val; @@ -138,8 +140,17 @@ private void updateRegistry() throws InterruptedException { serviceRegistry.updateNodes(nodeList); } else { - log.warn("Empty list returned from node data source. We are in a weird state. Keeping old list for {}", - serviceRegistry.getService().getServiceName()); + // if existing node list is null or empty, just refresh it with empty list again + // to set the atomic boolean flag : refreshed as true + if(Objects.isNull(serviceRegistry.nodeList()) || serviceRegistry.nodeList().isEmpty()){ + log.debug("Empty list returned from node data source. Old list for {} was empty and refreshing it again with empty list", + serviceRegistry.getService().getServiceName()); + serviceRegistry.updateNodes(Collections.emptyList()); + } else { + // if existing node list is not null or not empty, retain it as it is + log.warn("Empty list returned from node data source. We are in a weird state. Keeping old list for {}", + serviceRegistry.getService().getServiceName()); + } } }