From f8090d94b2aebd7c01720caadc49c893d0ab6c28 Mon Sep 17 00:00:00 2001 From: Vedran Pavic Date: Thu, 3 Dec 2015 22:47:11 +0100 Subject: [PATCH] Add AbstractHealthAggregator.aggregateDetails Extract aggregate details logic to a protected method that can be overridden if required. Closes gh-4674 --- .../health/AbstractHealthAggregator.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java index 82e799bbc9..dee7888c5e 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java @@ -26,6 +26,7 @@ import java.util.Map; * aggregating the {@link Status} instances and not deal with contextual details etc. * * @author Christian Dupuis + * @author Vedran Pavic * @since 1.1.0 */ public abstract class AbstractHealthAggregator implements HealthAggregator { @@ -33,12 +34,12 @@ public abstract class AbstractHealthAggregator implements HealthAggregator { @Override public final Health aggregate(Map healths) { List statusCandidates = new ArrayList(); - Map details = new LinkedHashMap(); for (Map.Entry entry : healths.entrySet()) { - details.put(entry.getKey(), entry.getValue()); statusCandidates.add(entry.getValue().getStatus()); } - return new Health.Builder(aggregateStatus(statusCandidates), details).build(); + Status status = aggregateStatus(statusCandidates); + Map details = aggregateDetails(healths); + return new Health.Builder(status, details).build(); } /** @@ -49,4 +50,15 @@ public abstract class AbstractHealthAggregator implements HealthAggregator { */ protected abstract Status aggregateStatus(List candidates); + /** + * Return the map of 'aggregate' details that should be used from the specified + * healths. + * @param healths the health instances to aggregate + * @return a map of details + * @since 1.3.1 + */ + protected Map aggregateDetails(Map healths) { + return new LinkedHashMap(healths); + } + }