Filter empty health contributions
Update `HealthEndpointSupport` so that aggregate elements that don't ultimately provide a contribution are filtered out. Prior to this commit an NPE was returned when calculating the aggregate status. Fixes gh-18687
This commit is contained in:
@@ -207,6 +207,14 @@ abstract class HealthEndpointSupportTests<R extends ContributorRegistry<C>, C, T
|
||||
assertThat(getHealth(result)).isNotInstanceOf(SystemHealth.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getHealthWithEmptyCompositeReturnsNullResult() { // gh-18687
|
||||
this.registry.registerContributor("test", createCompositeContributor(Collections.emptyMap()));
|
||||
HealthResult<T> result = create(this.registry, this.groups).getHealth(ApiVersion.V3, SecurityContext.NONE,
|
||||
false);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
protected abstract HealthEndpointSupport<C, T> create(R registry, HealthEndpointGroups groups);
|
||||
|
||||
protected abstract R createRegistry();
|
||||
|
||||
Reference in New Issue
Block a user