From 183c22b6844e97c6352fcae68591d39400d4047d Mon Sep 17 00:00:00 2001 From: Charles Stein Date: Fri, 10 May 2024 15:01:57 -0300 Subject: [PATCH] replace usage of var and status imports --- .../server/health/ActuatorGrpcHealth.java | 23 ++++++++++--------- ...hServiceTrueActuatorConfigurationTest.java | 2 +- .../server/health/ActuatorGrpcHealthTest.java | 4 ++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/grpc-server-spring-boot-starter/src/main/java/net/devh/boot/grpc/server/health/ActuatorGrpcHealth.java b/grpc-server-spring-boot-starter/src/main/java/net/devh/boot/grpc/server/health/ActuatorGrpcHealth.java index 3fcd234cd..fe902fce3 100644 --- a/grpc-server-spring-boot-starter/src/main/java/net/devh/boot/grpc/server/health/ActuatorGrpcHealth.java +++ b/grpc-server-spring-boot-starter/src/main/java/net/devh/boot/grpc/server/health/ActuatorGrpcHealth.java @@ -16,11 +16,13 @@ package net.devh.boot.grpc.server.health; -import java.util.Objects; +import static io.grpc.Status.NOT_FOUND; + +import org.springframework.boot.actuate.health.HealthComponent; import org.springframework.boot.actuate.health.HealthEndpoint; +import org.springframework.boot.actuate.health.Status; -import io.grpc.Status; import io.grpc.StatusException; import io.grpc.health.v1.HealthCheckRequest; import io.grpc.health.v1.HealthCheckResponse; @@ -37,20 +39,20 @@ public ActuatorGrpcHealth(HealthEndpoint healthEndpoint) { public void check(HealthCheckRequest request, StreamObserver responseObserver) { if (!request.getService().isEmpty()) { - var health = healthEndpoint.healthForPath(request.getService()); + HealthComponent health = healthEndpoint.healthForPath(request.getService()); if (health == null) { - responseObserver.onError(new StatusException( - Status.NOT_FOUND.withDescription("unknown service " + request.getService()))); + responseObserver.onError( + new StatusException(NOT_FOUND.withDescription("unknown service " + request.getService()))); return; } - var status = health.getStatus(); + Status status = health.getStatus(); HealthCheckResponse.ServingStatus result = resolveStatus(status); HealthCheckResponse response = HealthCheckResponse.newBuilder().setStatus(result).build(); responseObserver.onNext(response); responseObserver.onCompleted(); } else { - var status = healthEndpoint.health().getStatus(); + Status status = healthEndpoint.health().getStatus(); HealthCheckResponse.ServingStatus result = resolveStatus(status); HealthCheckResponse response = HealthCheckResponse.newBuilder().setStatus(result).build(); responseObserver.onNext(response); @@ -59,12 +61,11 @@ public void check(HealthCheckRequest request, StreamObserver