From 3502d780735b537f29ec398745a7ed264805ac9b Mon Sep 17 00:00:00 2001 From: GuangrongFu Date: Thu, 3 Mar 2022 11:33:59 +0800 Subject: bugfix - fixed the healthcheck problem Issue-ID: HOLMES-512 Signed-off-by: GuangrongFu Change-Id: I4393c649468157c00f3ea57568056b087b76554c --- .../java/org/onap/holmes/rulemgt/Initializer.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'rulemgt/src/main/java/org/onap') diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java index 812ee48..3995e4c 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/Initializer.java @@ -30,6 +30,7 @@ import javax.annotation.PostConstruct; import javax.inject.Inject; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import static org.onap.holmes.common.utils.CommonUtils.getEnv; @@ -38,7 +39,7 @@ import static org.onap.holmes.common.utils.CommonUtils.isIpAddress; @Service public class Initializer { private static final Logger logger = LoggerFactory.getLogger(Initializer.class); - private static boolean readyForMsbReg = false; + private volatile static boolean readyForMsbReg = false; private MsbRegister msbRegister; @Inject @@ -48,17 +49,19 @@ public class Initializer { @PostConstruct private void init() { - waitUntilReady(); - try { - msbRegister.register2Msb(createMicroServiceInfo()); - } catch (CorrelationException e) { - logger.error(e.getMessage(), e); - } + Executors.newSingleThreadExecutor().execute(() -> { + waitUntilReady(); + try { + msbRegister.register2Msb(createMicroServiceInfo()); + } catch (CorrelationException e) { + logger.error(e.getMessage(), e); + } + }); } private void waitUntilReady() { int count = 1; - while(!readyForMsbReg) { + while (!readyForMsbReg) { if (count > 20) { break; } -- cgit 1.2.3-korg