Skip to content

Commit 3328849

Browse files
committed
Remove exception field from Health class
Closes gh-34030
1 parent d71d885 commit 3328849

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractReactiveHealthIndicator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ protected AbstractReactiveHealthIndicator(Function<Throwable, String> healthChec
7676

7777
@Override
7878
public final Mono<Health> health() {
79-
Mono<Health> result;
8079
try {
81-
result = doHealthCheck(new Health.Builder()).onErrorResume(this::handleFailure);
80+
Health.Builder builder = new Health.Builder();
81+
Mono<Health> result = doHealthCheck(builder).onErrorResume(this::handleFailure);
82+
return result.doOnNext((health) -> logExceptionIfPresent(builder.getException()));
8283
}
8384
catch (Exception ex) {
84-
result = handleFailure(ex);
85+
return handleFailure(ex);
8586
}
86-
return result.doOnNext((health) -> logExceptionIfPresent(health.getException()));
8787
}
8888

8989
private void logExceptionIfPresent(Throwable ex) {
@@ -94,6 +94,7 @@ private void logExceptionIfPresent(Throwable ex) {
9494
}
9595

9696
private Mono<Health> handleFailure(Throwable ex) {
97+
logExceptionIfPresent(ex);
9798
return Mono.just(new Health.Builder().down(ex).build());
9899
}
99100

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Health.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.LinkedHashMap;
2121
import java.util.Map;
2222

23-
import com.fasterxml.jackson.annotation.JsonIgnore;
2423
import com.fasterxml.jackson.annotation.JsonInclude;
2524
import com.fasterxml.jackson.annotation.JsonInclude.Include;
2625

@@ -47,7 +46,6 @@
4746
* @author Christian Dupuis
4847
* @author Phillip Webb
4948
* @author Michael Pratt
50-
* @author Moritz Halbritter
5149
* @since 1.1.0
5250
*/
5351
@JsonInclude(Include.NON_EMPTY)
@@ -57,8 +55,6 @@ public final class Health extends HealthComponent {
5755

5856
private final Map<String, Object> details;
5957

60-
private final Throwable exception;
61-
6258
/**
6359
* Create a new {@link Health} instance with the specified status and details.
6460
* @param builder the Builder to use
@@ -67,13 +63,11 @@ private Health(Builder builder) {
6763
Assert.notNull(builder, "Builder must not be null");
6864
this.status = builder.status;
6965
this.details = Collections.unmodifiableMap(builder.details);
70-
this.exception = builder.exception;
7166
}
7267

7368
Health(Status status, Map<String, Object> details) {
7469
this.status = status;
7570
this.details = details;
76-
this.exception = null;
7771
}
7872

7973
/**
@@ -107,11 +101,6 @@ Health withoutDetails() {
107101
return status(getStatus()).build();
108102
}
109103

110-
@JsonIgnore
111-
Throwable getException() {
112-
return this.exception;
113-
}
114-
115104
@Override
116105
public boolean equals(Object obj) {
117106
if (obj == this) {
@@ -202,7 +191,7 @@ public static class Builder {
202191

203192
private Status status;
204193

205-
private Map<String, Object> details;
194+
private final Map<String, Object> details;
206195

207196
private Throwable exception;
208197

0 commit comments

Comments
 (0)