Skip to content

Commit 10de888

Browse files
polarbear567philwebb
authored andcommitted
Inherit show-details property in health groups
Update `Group` properties so that the `showDetails` value does not inherit `Show.NEVER`. Prior to this commit, the `Group` properties would not correctly inherit a `showDetails` value from the main `management.endpoint.health.show-details` property. See gh-22022
1 parent bf04bab commit 10de888

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* Configuration properties for {@link HealthEndpoint}.
2828
*
2929
* @author Phillip Webb
30+
* @author Leo Li
3031
* @since 2.0.0
3132
*/
3233
@ConfigurationProperties("management.endpoint.health")
@@ -56,6 +57,11 @@ public static class Group extends HealthProperties {
5657
*/
5758
private Set<String> exclude;
5859

60+
/**
61+
* The default value of this field should be null for group.
62+
*/
63+
private Show showDetails;
64+
5965
public Set<String> getInclude() {
6066
return this.include;
6167
}
@@ -72,6 +78,16 @@ public void setExclude(Set<String> exclude) {
7278
this.exclude = exclude;
7379
}
7480

81+
@Override
82+
public Show getShowDetails() {
83+
return this.showDetails;
84+
}
85+
86+
@Override
87+
public void setShowDetails(Show showDetails) {
88+
this.showDetails = showDetails;
89+
}
90+
7591
}
7692

7793
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* Tests for {@link AutoConfiguredHealthEndpointGroups}.
4444
*
4545
* @author Phillip Webb
46+
* @author Leo Li
4647
*/
4748
class AutoConfiguredHealthEndpointGroupsTests {
4849

@@ -308,6 +309,16 @@ void createWhenHasGroupSpecificHttpCodeStatusMapperPropertyAndGroupQualifiedBean
308309
});
309310
}
310311

312+
@Test
313+
void createWhenNoDefinedGroupsShowDetails() {
314+
this.contextRunner.withPropertyValues("management.endpoint.health.show-details=always",
315+
"management.endpoint.health.group.a.include=*").run((context) -> {
316+
HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
317+
HealthEndpointGroup groupA = groups.get("a");
318+
assertThat(groupA.showDetails(SecurityContext.NONE)).isTrue();
319+
});
320+
}
321+
311322
@Configuration(proxyBeanMethods = false)
312323
@EnableConfigurationProperties(HealthEndpointProperties.class)
313324
static class AutoConfiguredHealthEndpointGroupsTestConfiguration {

0 commit comments

Comments
 (0)