Polish "Honor gRPC overall health setting"

See gh-50799
This commit is contained in:
Stéphane Nicoll
2026-07-23 14:17:38 +02:00
parent da318b2540
commit e2b4c93c57
2 changed files with 9 additions and 10 deletions
@@ -68,10 +68,8 @@ class AutoConfiguredHealthCheckedGrpcComponents implements HealthCheckedGrpcComp
() -> StatusAggregator.of(properties.getStatus().getOrder()));
StatusMapper statusMapper = getNonQualifiedBean(beanFactory, StatusMapper.class,
() -> StatusMapper.of(properties.getStatus().getMapping()));
this.server = (properties.isIncludeOverallHealth())
? new AutoConfiguredHealthCheckedGrpcComponent(HealthContributorMembership.always(), statusAggregator,
statusMapper)
: null;
this.server = (properties.isIncludeOverallHealth()) ? new AutoConfiguredHealthCheckedGrpcComponent(
HealthContributorMembership.always(), statusAggregator, statusMapper) : null;
this.services = createServices(properties.getService(), beanFactory, statusAggregator, statusMapper);
}
@@ -304,12 +304,13 @@ class GrpcServerHealthAutoConfigurationTests {
@Test
void whenIncludeOverallHealthIsFalseDoesNotReportOverallHealth() {
this.contextRunner.withPropertyValues("spring.grpc.server.health.include-overall-health=false").run((context) -> {
GrpcServerHealth serverHealth = context.getBean(GrpcServerHealth.class);
Map<String, ServingStatus> result = new LinkedHashMap<>();
serverHealth.update(result::put);
assertThat(result).isEmpty();
});
this.contextRunner.withPropertyValues("spring.grpc.server.health.include-overall-health=false")
.run((context) -> {
GrpcServerHealth serverHealth = context.getBean(GrpcServerHealth.class);
Map<String, ServingStatus> result = new LinkedHashMap<>();
serverHealth.update(result::put);
assertThat(result).isEmpty();
});
}
@Test