Skip to content

Commit d526466

Browse files
committed
Merge branch '2.3.x' into 2.4.x
Closes gh-26822
2 parents 4d62e47 + 1f6983c commit d526466

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ public Map<String, HealthComponent> getComponents() {
6666

6767
@JsonInclude(Include.NON_EMPTY)
6868
@JsonProperty
69-
Map<String, HealthComponent> getDetails() {
69+
public Map<String, HealthComponent> getDetails() {
7070
return this.details;
7171
}
7272

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeHealthTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import java.util.LinkedHashMap;
2121
import java.util.Map;
2222

23+
import com.fasterxml.jackson.databind.MapperFeature;
2324
import com.fasterxml.jackson.databind.ObjectMapper;
2425
import org.junit.jupiter.api.Test;
2526

@@ -80,4 +81,17 @@ void serializeV2WithJacksonReturnsValidJson() throws Exception {
8081
+ "\"db2\":{\"status\":\"DOWN\",\"details\":{\"a\":\"b\"}}}}");
8182
}
8283

84+
@Test // gh-26797
85+
void serializeV2WithJacksonAndDisabledCanOverrideAccessModifiersReturnsValidJson() throws Exception {
86+
Map<String, HealthComponent> components = new LinkedHashMap<>();
87+
components.put("db1", Health.up().build());
88+
components.put("db2", Health.down().withDetail("a", "b").build());
89+
CompositeHealth health = new CompositeHealth(ApiVersion.V2, Status.UP, components);
90+
ObjectMapper mapper = new ObjectMapper();
91+
mapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
92+
String json = mapper.writeValueAsString(health);
93+
assertThat(json).isEqualTo("{\"status\":\"UP\",\"details\":{\"db1\":{\"status\":\"UP\"},"
94+
+ "\"db2\":{\"status\":\"DOWN\",\"details\":{\"a\":\"b\"}}}}");
95+
}
96+
8397
}

0 commit comments

Comments
 (0)