Skip to content

Commit e2b4c93

Browse files
committed
Polish "Honor gRPC overall health setting"
See gh-50799
1 parent da318b2 commit e2b4c93

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/AutoConfiguredHealthCheckedGrpcComponents.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ class AutoConfiguredHealthCheckedGrpcComponents implements HealthCheckedGrpcComp
6868
() -> StatusAggregator.of(properties.getStatus().getOrder()));
6969
StatusMapper statusMapper = getNonQualifiedBean(beanFactory, StatusMapper.class,
7070
() -> StatusMapper.of(properties.getStatus().getMapping()));
71-
this.server = (properties.isIncludeOverallHealth())
72-
? new AutoConfiguredHealthCheckedGrpcComponent(HealthContributorMembership.always(), statusAggregator,
73-
statusMapper)
74-
: null;
71+
this.server = (properties.isIncludeOverallHealth()) ? new AutoConfiguredHealthCheckedGrpcComponent(
72+
HealthContributorMembership.always(), statusAggregator, statusMapper) : null;
7573
this.services = createServices(properties.getService(), beanFactory, statusAggregator, statusMapper);
7674
}
7775

module/spring-boot-grpc-server/src/test/java/org/springframework/boot/grpc/server/autoconfigure/health/GrpcServerHealthAutoConfigurationTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,13 @@ void createsGrpcServerHealth() {
304304

305305
@Test
306306
void whenIncludeOverallHealthIsFalseDoesNotReportOverallHealth() {
307-
this.contextRunner.withPropertyValues("spring.grpc.server.health.include-overall-health=false").run((context) -> {
308-
GrpcServerHealth serverHealth = context.getBean(GrpcServerHealth.class);
309-
Map<String, ServingStatus> result = new LinkedHashMap<>();
310-
serverHealth.update(result::put);
311-
assertThat(result).isEmpty();
312-
});
307+
this.contextRunner.withPropertyValues("spring.grpc.server.health.include-overall-health=false")
308+
.run((context) -> {
309+
GrpcServerHealth serverHealth = context.getBean(GrpcServerHealth.class);
310+
Map<String, ServingStatus> result = new LinkedHashMap<>();
311+
serverHealth.update(result::put);
312+
assertThat(result).isEmpty();
313+
});
313314
}
314315

315316
@Test

0 commit comments

Comments
 (0)