Skip to content

Commit e6eb026

Browse files
committed
Polish 'Inherit show-details property in health groups'
Rework the inheritance so that the property metadata JSON more accurately reflects the default value. See gh-22022
1 parent 10de888 commit e6eb026

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

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

Lines changed: 17 additions & 3 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.
@@ -33,11 +33,25 @@
3333
@ConfigurationProperties("management.endpoint.health")
3434
public class HealthEndpointProperties extends HealthProperties {
3535

36+
/**
37+
* When to show full health details.
38+
*/
39+
private Show showDetails = Show.NEVER;
40+
3641
/**
3742
* Health endpoint groups.
3843
*/
3944
private Map<String, Group> group = new LinkedHashMap<>();
4045

46+
@Override
47+
public Show getShowDetails() {
48+
return this.showDetails;
49+
}
50+
51+
public void setShowDetails(Show showDetails) {
52+
this.showDetails = showDetails;
53+
}
54+
4155
public Map<String, Group> getGroup() {
4256
return this.group;
4357
}
@@ -58,7 +72,8 @@ public static class Group extends HealthProperties {
5872
private Set<String> exclude;
5973

6074
/**
61-
* The default value of this field should be null for group.
75+
* When to show full health details. Defaults to the value of
76+
* 'management.endpoint.health.show-details'.
6277
*/
6378
private Show showDetails;
6479

@@ -83,7 +98,6 @@ public Show getShowDetails() {
8398
return this.showDetails;
8499
}
85100

86-
@Override
87101
public void setShowDetails(Show showDetails) {
88102
this.showDetails = showDetails;
89103
}

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: 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-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.
@@ -310,7 +310,7 @@ void createWhenHasGroupSpecificHttpCodeStatusMapperPropertyAndGroupQualifiedBean
310310
}
311311

312312
@Test
313-
void createWhenNoDefinedGroupsShowDetails() {
313+
void createWhenGroupWithNoShowDetailsOverrideInheritsShowDetails() {
314314
this.contextRunner.withPropertyValues("management.endpoint.health.show-details=always",
315315
"management.endpoint.health.group.a.include=*").run((context) -> {
316316
HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);

0 commit comments

Comments
 (0)