From fe8fcaeaff3a330d0d04a8d666dcd2cc9cf8d68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 24 Mar 2026 11:28:37 +0100 Subject: [PATCH] Polish --- .../grpc/client/autoconfigure/ServiceConfig.java | 4 ++-- .../grpc/server/GrpcServletRegistration.java | 2 +- .../grpc/server/autoconfigure/NettyAddress.java | 2 +- ...utoConfiguredHealthCheckedGrpcComponents.java | 2 +- .../GrpcServerHealthAutoConfiguration.java | 4 ++-- .../security/GrpcDisableCsrfHttpConfigurer.java | 2 +- .../security/web/reactive/GrpcRequest.java | 2 +- .../security/web/servlet/GrpcRequest.java | 4 ++-- .../grpc/server/health/GrpcServerHealth.java | 16 ++++++++-------- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/module/spring-boot-grpc-client/src/main/java/org/springframework/boot/grpc/client/autoconfigure/ServiceConfig.java b/module/spring-boot-grpc-client/src/main/java/org/springframework/boot/grpc/client/autoconfigure/ServiceConfig.java index 1ddd11a3a62..8491084289a 100644 --- a/module/spring-boot-grpc-client/src/main/java/org/springframework/boot/grpc/client/autoconfigure/ServiceConfig.java +++ b/module/spring-boot-grpc-client/src/main/java/org/springframework/boot/grpc/client/autoconfigure/ServiceConfig.java @@ -182,7 +182,7 @@ public record ServiceConfig(@Nullable List loadbalancing, @ * @param outOfBandReportingPeriod load reporting interval to request from the * server * @param enableOutOfBandLoadReport whether to enable out-of-band utilization - * reporting collection from the endpoints + * reporting collections from the endpoints * @param weightUpdatePeriod how often endpoint weights are recalculated * @param errorUtilizationPenalty multiplier used to adjust endpoint weights with * the error rate calculated as eps/qps @@ -327,7 +327,7 @@ public record ServiceConfig(@Nullable List loadbalancing, @ * @param maxBackoff maximum exponential backoff * @param backoffMultiplier exponential backoff multiplier * @param perAttemptReceiveTimeout per-attempt receive timeout - * @param retryableStatusCodes status codes which may be retried + * @param retryableStatusCodes status codes that may be retried */ public record RetryPolicy(Integer maxAttempts, Duration initialBackoff, Duration maxBackoff, Double backoffMultiplier, Duration perAttemptReceiveTimeout, Set retryableStatusCodes) { diff --git a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/GrpcServletRegistration.java b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/GrpcServletRegistration.java index 1ddbbaf9d9b..2b9185db55f 100644 --- a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/GrpcServletRegistration.java +++ b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/GrpcServletRegistration.java @@ -49,7 +49,7 @@ import org.springframework.util.ObjectUtils; */ public class GrpcServletRegistration extends DynamicRegistrationBean { - private static Log logger = LogFactory.getLog(GrpcServletRegistration.class); + private static final Log logger = LogFactory.getLog(GrpcServletRegistration.class); private final GrpcServlet servlet; diff --git a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/NettyAddress.java b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/NettyAddress.java index 4e66805002a..077881fa1c4 100644 --- a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/NettyAddress.java +++ b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/NettyAddress.java @@ -40,7 +40,7 @@ record NettyAddress(@Nullable Transport transport, @Nullable InetAddress address @Nullable String domainSocketPath) { @Override - public final String toString() { + public String toString() { Transport transport = (this.transport != null) ? this.transport : deduceTransport(); return switch (transport) { case TCP -> tcpAddress(); diff --git a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/AutoConfiguredHealthCheckedGrpcComponents.java b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/AutoConfiguredHealthCheckedGrpcComponents.java index 98248c2b885..bdee841ba66 100644 --- a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/AutoConfiguredHealthCheckedGrpcComponents.java +++ b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/AutoConfiguredHealthCheckedGrpcComponents.java @@ -58,7 +58,7 @@ class AutoConfiguredHealthCheckedGrpcComponents implements HealthCheckedGrpcComp /** * Create a new {@link AutoConfiguredHealthCheckedGrpcComponents} instance. * @param applicationContext the application context used to check for override beans - * @param properties the grpc server health properties + * @param properties the gRPC server health properties */ AutoConfiguredHealthCheckedGrpcComponents(ApplicationContext applicationContext, GrpcServerHealthProperties properties) { diff --git a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/GrpcServerHealthAutoConfiguration.java b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/GrpcServerHealthAutoConfiguration.java index f525a6e77b6..18b6c12cbab 100644 --- a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/GrpcServerHealthAutoConfiguration.java +++ b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/GrpcServerHealthAutoConfiguration.java @@ -113,8 +113,8 @@ public final class GrpcServerHealthAutoConfiguration { reactiveHealthContributorRegistry.getIfAvailable(), VALIDATE_MEMBERSHIP_PROPERTY, (members) -> properties.getService().forEach((serviceName, service) -> { String property = "spring.grpc.server.health.service." + serviceName; - members.member(property + ".include".formatted(serviceName), service.getInclude()); - members.member(property + ".exclude".formatted(serviceName), service.getExclude()); + members.member(property + ".include", service.getInclude()); + members.member(property + ".exclude", service.getExclude()); })); } diff --git a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/GrpcDisableCsrfHttpConfigurer.java b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/GrpcDisableCsrfHttpConfigurer.java index fa407365734..1b889389bd2 100644 --- a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/GrpcDisableCsrfHttpConfigurer.java +++ b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/GrpcDisableCsrfHttpConfigurer.java @@ -74,7 +74,7 @@ class GrpcDisableCsrfHttpConfigurer extends AbstractHttpConfigurer candidate.equals(service)); + return this.excludes.stream().noneMatch((candidate) -> candidate.equals(service)); } private String getPath(String service) { diff --git a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/web/servlet/GrpcRequest.java b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/web/servlet/GrpcRequest.java index f2eb644214f..2641c6883a2 100644 --- a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/web/servlet/GrpcRequest.java +++ b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/web/servlet/GrpcRequest.java @@ -110,7 +110,7 @@ public final class GrpcRequest { this.delegate = createDelegate(context.get()); } - private @Nullable RequestMatcher createDelegate(GrpcServiceDiscoverer grpcServiceDiscoverer) { + private RequestMatcher createDelegate(GrpcServiceDiscoverer grpcServiceDiscoverer) { List delegateMatchers = getDelegateMatchers(grpcServiceDiscoverer); return (!CollectionUtils.isEmpty(delegateMatchers)) ? new OrRequestMatcher(delegateMatchers) : EMPTY_MATCHER; @@ -125,7 +125,7 @@ public final class GrpcRequest { } private boolean isExcluded(String service) { - return !this.excludes.stream().anyMatch((candidate) -> candidate.equals(service)); + return this.excludes.stream().noneMatch((candidate) -> candidate.equals(service)); } private String getPath(String service) { diff --git a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/health/GrpcServerHealth.java b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/health/GrpcServerHealth.java index 0ff80ca4cc6..b4c2bb056fb 100644 --- a/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/health/GrpcServerHealth.java +++ b/module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/health/GrpcServerHealth.java @@ -44,11 +44,11 @@ import org.springframework.util.Assert; */ public class GrpcServerHealth { - private HealthContributorRegistry registry; + private final HealthContributorRegistry registry; - private @Nullable ReactiveHealthContributorRegistry fallbackRegistry; + private final @Nullable ReactiveHealthContributorRegistry fallbackRegistry; - private HealthCheckedGrpcComponents components; + private final HealthCheckedGrpcComponents components; /** * Create a new {@link GrpcServerHealth} instance. @@ -69,16 +69,16 @@ public class GrpcServerHealth { update(manager::setStatus); } - public void update(BiConsumer updator) { + public void update(BiConsumer updater) { Cache cache = new Cache(); HealthCheckedGrpcComponent serverComponent = this.components.getServer(); if (serverComponent != null) { - updator.accept("", getServingStatus(cache, serverComponent)); + updater.accept("", getServingStatus(cache, serverComponent)); } for (String serviceName : this.components.getServiceNames()) { HealthCheckedGrpcComponent serviceComponent = this.components.getService(serviceName); if (!serviceName.isEmpty() && serviceComponent != null) { - updator.accept(serviceName, getServingStatus(cache, serviceComponent)); + updater.accept(serviceName, getServingStatus(cache, serviceComponent)); } } } @@ -109,11 +109,11 @@ public class GrpcServerHealth { } } - class Cache { + static class Cache { private final Map health = new HashMap<>(); - Health getHealth(String name, HealthIndicator indicator) { + @Nullable Health getHealth(String name, HealthIndicator indicator) { return this.health.computeIfAbsent(name, (key) -> indicator.health(false)); }