From df3304427d0e0b3f9e420c0dad7f124c32b17fda Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Wed, 29 Dec 2021 20:35:36 +0800 Subject: [PATCH] =?UTF-8?q?Spring=20=E4=B8=8A=E4=B8=8B=E6=96=87=E6=97=A0?= =?UTF-8?q?=E7=88=B6=E7=B1=BB=E6=97=B6=E6=97=A0=E6=B3=95=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98.=20(#48)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starter/remote/AbstractHealthCheck.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/AbstractHealthCheck.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/AbstractHealthCheck.java index b67145fe..f40d8e07 100644 --- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/AbstractHealthCheck.java +++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/remote/AbstractHealthCheck.java @@ -1,12 +1,12 @@ package cn.hippo4j.starter.remote; import cn.hippo4j.starter.core.ShutdownExecuteException; +import cn.hippo4j.starter.event.ApplicationCompleteEvent; import cn.hippo4j.starter.toolkit.thread.ThreadFactoryBuilder; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; import java.util.Objects; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -23,7 +23,7 @@ import static cn.hippo4j.common.constant.Constants.HEALTH_CHECK_INTERVAL; * @date 2021/12/8 20:19 */ @Slf4j -public abstract class AbstractHealthCheck implements ServerHealthCheck, InitializingBean, ApplicationListener { +public abstract class AbstractHealthCheck implements ServerHealthCheck, InitializingBean, ApplicationListener { /** * Health status @@ -36,7 +36,7 @@ public abstract class AbstractHealthCheck implements ServerHealthCheck, Initiali private volatile boolean clientShutdownHook = false; /** - * Spring context init complete + * Spring context init complete. TODO: Why this */ private boolean contextInitComplete = false; @@ -136,12 +136,8 @@ public abstract class AbstractHealthCheck implements ServerHealthCheck, Initiali } @Override - public void onApplicationEvent(ContextRefreshedEvent event) { - synchronized (ServerHealthCheck.class) { - if (event.getApplicationContext().getParent() == null) { - contextInitComplete = true; - } - } + public void onApplicationEvent(ApplicationCompleteEvent event) { + contextInitComplete = true; } }