From 64a7c1757da6763d1aa18e5445f5ee2e19947ae6 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 28 Jun 2022 20:13:53 +0900 Subject: [PATCH] Polish gh-31231 See gh-31231 --- .../autoconfigure/health/HealthEndpointProperties.java | 6 +++--- .../springframework/boot/actuate/health/HealthEndpoint.java | 1 + .../boot/actuate/health/HealthEndpointSupport.java | 4 ++-- .../boot/actuate/health/HealthEndpointWebExtension.java | 1 + .../actuate/health/ReactiveHealthEndpointWebExtension.java | 1 + .../src/docs/asciidoc/actuator/endpoints.adoc | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointProperties.java index 9b5466bfe89e..c6c0a53e5fe3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointProperties.java @@ -42,9 +42,9 @@ public class HealthEndpointProperties extends HealthProperties { /** * Health endpoint groups. */ - private Map group = new LinkedHashMap<>(); + private final Map group = new LinkedHashMap<>(); - private Logging logging = new Logging(); + private final Logging logging = new Logging(); @Override public Show getShowDetails() { @@ -139,7 +139,7 @@ public static class Logging { /** * Threshold after which a warning will be logged for slow health indicators. */ - Duration slowIndicatorThreshold = Duration.ofSeconds(10); + private Duration slowIndicatorThreshold = Duration.ofSeconds(10); public Duration getSlowIndicatorThreshold() { return this.slowIndicatorThreshold; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java index d2f7eae830a8..5a2aee920ce3 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java @@ -66,6 +66,7 @@ public HealthEndpoint(HealthContributorRegistry registry, HealthEndpointGroups g * @param groups the health endpoint groups * @param slowIndicatorLoggingThreshold duration after which slow health indicator * logging should occur + * @since 2.6.9 */ public HealthEndpoint(HealthContributorRegistry registry, HealthEndpointGroups groups, Duration slowIndicatorLoggingThreshold) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java index 59c13a8314a8..7ae4e11793de 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java @@ -52,7 +52,7 @@ abstract class HealthEndpointSupport { private final HealthEndpointGroups groups; - private Duration slowIndicatorLoggingThreshold; + private final Duration slowIndicatorLoggingThreshold; /** * Create a new {@link HealthEndpointSupport} instance. @@ -177,7 +177,7 @@ private T getLoggedHealth(C contributor, String name, boolean showDetails) { if (duration.compareTo(this.slowIndicatorLoggingThreshold) > 0) { String contributorClassName = contributor.getClass().getName(); Object contributorIdentifier = (!StringUtils.hasLength(name)) ? contributorClassName - : contributor.getClass().getName() + " (" + name + ")"; + : contributorClassName + " (" + name + ")"; logger.warn(LogMessage.format("Health contributor %s took %s to respond", contributorIdentifier, DurationStyle.SIMPLE.print(duration))); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java index b96f3c07acde..e019e3e9bf5e 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointWebExtension.java @@ -66,6 +66,7 @@ public HealthEndpointWebExtension(HealthContributorRegistry registry, HealthEndp * @param groups the health endpoint groups * @param slowIndicatorLoggingThreshold duration after which slow health indicator * logging should occur + * @since 2.6.9 */ public HealthEndpointWebExtension(HealthContributorRegistry registry, HealthEndpointGroups groups, Duration slowIndicatorLoggingThreshold) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtension.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtension.java index 21e97b41d59b..7a1fc30ddb9e 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtension.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthEndpointWebExtension.java @@ -66,6 +66,7 @@ public ReactiveHealthEndpointWebExtension(ReactiveHealthContributorRegistry regi * @param groups the health endpoint groups * @param slowIndicatorLoggingThreshold duration after which slow health indicator * logging should occur + * @since 2.6.9 */ public ReactiveHealthEndpointWebExtension(ReactiveHealthContributorRegistry registry, HealthEndpointGroups groups, Duration slowIndicatorLoggingThreshold) { diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc index ca902ce23538..178babe51c0d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/actuator/endpoints.adoc @@ -746,7 +746,7 @@ In the preceding example, the health information is available in an entry named TIP: Health indicators are usually called over HTTP and need to respond before any connection timeouts. Spring Boot will log a warning message for any health indicator that takes longer than 10 seconds to respond. -If you want to configure this threshold, you can use the configprop:management.endpoint.health.logging.slow-indicator-threshold[] property +If you want to configure this threshold, you can use the configprop:management.endpoint.health.logging.slow-indicator-threshold[] property. In addition to Spring Boot's predefined {spring-boot-actuator-module-code}/health/Status.java[`Status`] types, `Health` can return a custom `Status` that represents a new system state. In such cases, you also need to provide a custom implementation of the {spring-boot-actuator-module-code}/health/StatusAggregator.java[`StatusAggregator`] interface, or you must configure the default implementation by using the configprop:management.endpoint.health.status.order[] configuration property.