Skip to content

Commit 03b0a37

Browse files
committed
Merge branch '2.2.x' into 2.3.x
Closes gh-22063
2 parents f296f57 + a49156d commit 03b0a37

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

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

Lines changed: 31 additions & 1 deletion
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-2020 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.
@@ -27,16 +27,31 @@
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")
3334
public class HealthEndpointProperties extends HealthProperties {
3435

36+
/**
37+
* When to show full health details.
38+
*/
39+
private Show showDetails = Show.NEVER;
40+
3541
/**
3642
* Health endpoint groups.
3743
*/
3844
private Map<String, Group> group = new LinkedHashMap<>();
3945

46+
@Override
47+
public Show getShowDetails() {
48+
return this.showDetails;
49+
}
50+
51+
public void setShowDetails(Show showDetails) {
52+
this.showDetails = showDetails;
53+
}
54+
4055
public Map<String, Group> getGroup() {
4156
return this.group;
4257
}
@@ -56,6 +71,12 @@ public static class Group extends HealthProperties {
5671
*/
5772
private Set<String> exclude;
5873

74+
/**
75+
* When to show full health details. Defaults to the value of
76+
* 'management.endpoint.health.show-details'.
77+
*/
78+
private Show showDetails;
79+
5980
public Set<String> getInclude() {
6081
return this.include;
6182
}
@@ -72,6 +93,15 @@ public void setExclude(Set<String> exclude) {
7293
this.exclude = exclude;
7394
}
7495

96+
@Override
97+
public Show getShowDetails() {
98+
return this.showDetails;
99+
}
100+
101+
public void setShowDetails(Show showDetails) {
102+
this.showDetails = showDetails;
103+
}
104+
75105
}
76106

77107
}

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

Lines changed: 2 additions & 13 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-2020 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.
@@ -43,11 +43,6 @@ public abstract class HealthProperties {
4343
*/
4444
private Show showComponents;
4545

46-
/**
47-
* When to show full health details.
48-
*/
49-
private Show showDetails = Show.NEVER;
50-
5146
/**
5247
* Roles used to determine whether or not a user is authorized to be shown details.
5348
* When empty, all authenticated users are authorized.
@@ -66,13 +61,7 @@ public void setShowComponents(Show showComponents) {
6661
this.showComponents = showComponents;
6762
}
6863

69-
public Show getShowDetails() {
70-
return this.showDetails;
71-
}
72-
73-
public void setShowDetails(Show showDetails) {
74-
this.showDetails = showDetails;
75-
}
64+
public abstract Show getShowDetails();
7665

7766
public Set<String> getRoles() {
7867
return this.roles;

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 createWhenGroupWithNoShowDetailsOverrideInheritsShowDetails() {
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)