From aaaa791ceab4f66f0cea348cb6e087398cd19d19 Mon Sep 17 00:00:00 2001 From: geniuus Date: Mon, 7 Apr 2025 01:36:38 +0900 Subject: [PATCH] Validate that sslInfo is not null in SslHealthIndicator constructor The SslHealthIndicator constructor previously did not validate if the provided SslInfo instance was null. This could potentially lead to a NullPointerException later when the doHealthCheck method is invoked if the SslInfo bean was not properly configured or available. This commit adds an Assert.notNull check for the sslInfo parameter to ensure fail-fast behavior during application startup or bean creation. This aligns with the common practice in other Spring Boot components and health indicators where essential dependencies are validated in the constructor. See gh-45013 Signed-off-by: geniuus --- .../springframework/boot/actuate/ssl/SslHealthIndicator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/ssl/SslHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/ssl/SslHealthIndicator.java index 18d8f2e1932..290852888ab 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/ssl/SslHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/ssl/SslHealthIndicator.java @@ -28,12 +28,14 @@ import org.springframework.boot.info.SslInfo; import org.springframework.boot.info.SslInfo.BundleInfo; import org.springframework.boot.info.SslInfo.CertificateChainInfo; import org.springframework.boot.info.SslInfo.CertificateInfo; +import org.springframework.util.Assert; /** * {@link HealthIndicator} that checks the certificates the application uses and reports * {@link Status#OUT_OF_SERVICE} when a certificate is invalid. * * @author Jonatan Ivanov + * @author Young Jae You * @since 3.4.0 */ public class SslHealthIndicator extends AbstractHealthIndicator { @@ -41,6 +43,8 @@ public class SslHealthIndicator extends AbstractHealthIndicator { private final SslInfo sslInfo; public SslHealthIndicator(SslInfo sslInfo) { + super("SSL health check failed"); + Assert.notNull(sslInfo, "'sslInfo' must not be null"); this.sslInfo = sslInfo; }