diff --git a/sofa-boot-project/sofa-boot-actuator/src/main/java/com/alipay/sofa/boot/actuator/health/MultiApplicationHealthIndicator.java b/sofa-boot-project/sofa-boot-actuator/src/main/java/com/alipay/sofa/boot/actuator/health/MultiApplicationHealthIndicator.java index 443c08988..6ca346c1b 100644 --- a/sofa-boot-project/sofa-boot-actuator/src/main/java/com/alipay/sofa/boot/actuator/health/MultiApplicationHealthIndicator.java +++ b/sofa-boot-project/sofa-boot-actuator/src/main/java/com/alipay/sofa/boot/actuator/health/MultiApplicationHealthIndicator.java @@ -16,6 +16,7 @@ */ package com.alipay.sofa.boot.actuator.health; +import com.alipay.sofa.ark.spi.model.Biz; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; @@ -35,16 +36,17 @@ public Health health() { boolean allPassed = true; Health.Builder builder = new Health.Builder(); for (SofaRuntimeManager sofaRuntimeManager : SofaFramework.getRuntimeSet()) { + Biz biz = DynamicJvmServiceProxyFinder.getBiz(sofaRuntimeManager); + if (biz == null) { + continue; + } + if (!sofaRuntimeManager.isLivenessHealth()) { allPassed = false; - builder.withDetail( - String.format("Biz: %s health check", - DynamicJvmServiceProxyFinder.getBiz(sofaRuntimeManager).getIdentity()), + builder.withDetail(String.format("Biz: %s health check", biz.getIdentity()), "failed"); } else { - builder.withDetail( - String.format("Biz: %s health check", - DynamicJvmServiceProxyFinder.getBiz(sofaRuntimeManager).getIdentity()), + builder.withDetail(String.format("Biz: %s health check", biz.getIdentity()), "passed"); } } diff --git a/sofa-boot-project/sofa-boot-core/healthcheck-sofa-boot/src/main/java/com/alipay/sofa/healthcheck/impl/SofaRuntimeHealthChecker.java b/sofa-boot-project/sofa-boot-core/healthcheck-sofa-boot/src/main/java/com/alipay/sofa/healthcheck/impl/SofaRuntimeHealthChecker.java index 08c73da6b..f8753dfc8 100644 --- a/sofa-boot-project/sofa-boot-core/healthcheck-sofa-boot/src/main/java/com/alipay/sofa/healthcheck/impl/SofaRuntimeHealthChecker.java +++ b/sofa-boot-project/sofa-boot-core/healthcheck-sofa-boot/src/main/java/com/alipay/sofa/healthcheck/impl/SofaRuntimeHealthChecker.java @@ -49,6 +49,10 @@ public boolean isReadinessHealth() { @Override public boolean isLivenessHealth() { for (HealthIndicator healthIndicator : healthIndicators) { + if (healthIndicator.getClass().getName() + .equals("com.alipay.sofa.boot.actuator.health.MultiApplicationHealthIndicator")) { + continue; + } if (healthIndicator.health().getStatus().equals(Status.DOWN)) { return false; } diff --git a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/invoke/DynamicJvmServiceProxyFinder.java b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/invoke/DynamicJvmServiceProxyFinder.java index c516d32de..0b832189b 100644 --- a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/invoke/DynamicJvmServiceProxyFinder.java +++ b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/invoke/DynamicJvmServiceProxyFinder.java @@ -150,6 +150,10 @@ private ServiceComponent findServiceComponent(String uniqueId, String interfaceT * @return */ public static Biz getBiz(SofaRuntimeManager sofaRuntimeManager) { + if (getDynamicJvmServiceProxyFinder().bizManagerService == null) { + return null; + } + for (Biz biz : getDynamicJvmServiceProxyFinder().bizManagerService.getBizInOrder()) { if (sofaRuntimeManager.getAppClassLoader().equals(biz.getBizClassLoader())) { return biz;