Skip to content

Commit

Permalink
Merge branch '2.7.x' into 3.0.x
Browse files Browse the repository at this point in the history
Closes gh-34070
  • Loading branch information
mhalbritter committed Feb 6, 2023
2 parents 3af30b0 + 3328849 commit 81c8574
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ protected AbstractReactiveHealthIndicator(Function<Throwable, String> healthChec

@Override
public final Mono<Health> health() {
Mono<Health> result;
try {
result = doHealthCheck(new Health.Builder()).onErrorResume(this::handleFailure);
Health.Builder builder = new Health.Builder();
Mono<Health> result = doHealthCheck(builder).onErrorResume(this::handleFailure);
return result.doOnNext((health) -> logExceptionIfPresent(builder.getException()));
}
catch (Exception ex) {
result = handleFailure(ex);
return handleFailure(ex);
}
return result.doOnNext((health) -> logExceptionIfPresent(health.getException()));
}

private void logExceptionIfPresent(Throwable ex) {
Expand All @@ -94,6 +94,7 @@ private void logExceptionIfPresent(Throwable ex) {
}

private Mono<Health> handleFailure(Throwable ex) {
logExceptionIfPresent(ex);
return Mono.just(new Health.Builder().down(ex).build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.LinkedHashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

Expand All @@ -47,7 +46,6 @@
* @author Christian Dupuis
* @author Phillip Webb
* @author Michael Pratt
* @author Moritz Halbritter
* @since 1.1.0
*/
@JsonInclude(Include.NON_EMPTY)
Expand All @@ -57,8 +55,6 @@ public final class Health extends HealthComponent {

private final Map<String, Object> details;

private final Throwable exception;

/**
* Create a new {@link Health} instance with the specified status and details.
* @param builder the Builder to use
Expand All @@ -67,13 +63,11 @@ private Health(Builder builder) {
Assert.notNull(builder, "Builder must not be null");
this.status = builder.status;
this.details = Collections.unmodifiableMap(builder.details);
this.exception = builder.exception;
}

Health(Status status, Map<String, Object> details) {
this.status = status;
this.details = details;
this.exception = null;
}

/**
Expand Down Expand Up @@ -107,11 +101,6 @@ Health withoutDetails() {
return status(getStatus()).build();
}

@JsonIgnore
Throwable getException() {
return this.exception;
}

@Override
public boolean equals(Object obj) {
if (obj == this) {
Expand Down

0 comments on commit 81c8574

Please sign in to comment.