Browse Source

Polish

pull/49740/head
Stéphane Nicoll 1 week ago
parent
commit
fe8fcaeaff
  1. 4
      module/spring-boot-grpc-client/src/main/java/org/springframework/boot/grpc/client/autoconfigure/ServiceConfig.java
  2. 2
      module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/GrpcServletRegistration.java
  3. 2
      module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/NettyAddress.java
  4. 2
      module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/AutoConfiguredHealthCheckedGrpcComponents.java
  5. 4
      module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/health/GrpcServerHealthAutoConfiguration.java
  6. 2
      module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/GrpcDisableCsrfHttpConfigurer.java
  7. 2
      module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/web/reactive/GrpcRequest.java
  8. 4
      module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/web/servlet/GrpcRequest.java
  9. 16
      module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/health/GrpcServerHealth.java

4
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<LoadBalancingConfig> loadbalancing, @ @@ -182,7 +182,7 @@ public record ServiceConfig(@Nullable List<LoadBalancingConfig> 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<LoadBalancingConfig> loadbalancing, @ @@ -327,7 +327,7 @@ public record ServiceConfig(@Nullable List<LoadBalancingConfig> 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<Status.Code> retryableStatusCodes) {

2
module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/GrpcServletRegistration.java

@ -49,7 +49,7 @@ import org.springframework.util.ObjectUtils; @@ -49,7 +49,7 @@ import org.springframework.util.ObjectUtils;
*/
public class GrpcServletRegistration extends DynamicRegistrationBean<Dynamic> {
private static Log logger = LogFactory.getLog(GrpcServletRegistration.class);
private static final Log logger = LogFactory.getLog(GrpcServletRegistration.class);
private final GrpcServlet servlet;

2
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 @@ -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();

2
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 @@ -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) {

4
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 { @@ -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());
}));
}

2
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<GrpcDisableCs @@ -74,7 +74,7 @@ class GrpcDisableCsrfHttpConfigurer extends AbstractHttpConfigurer<GrpcDisableCs
static class GrpcCsrfRequestMatcher implements RequestMatcher {
static GrpcCsrfRequestMatcher INSTANCE = new GrpcCsrfRequestMatcher();
static final GrpcCsrfRequestMatcher INSTANCE = new GrpcCsrfRequestMatcher();
@Override
public boolean matches(HttpServletRequest request) {

2
module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/security/web/reactive/GrpcRequest.java

@ -125,7 +125,7 @@ public final class GrpcRequest { @@ -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) {

4
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 { @@ -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<RequestMatcher> delegateMatchers = getDelegateMatchers(grpcServiceDiscoverer);
return (!CollectionUtils.isEmpty(delegateMatchers)) ? new OrRequestMatcher(delegateMatchers)
: EMPTY_MATCHER;
@ -125,7 +125,7 @@ public final class GrpcRequest { @@ -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) {

16
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; @@ -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 { @@ -69,16 +69,16 @@ public class GrpcServerHealth {
update(manager::setStatus);
}
public void update(BiConsumer<String, ServingStatus> updator) {
public void update(BiConsumer<String, ServingStatus> 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 { @@ -109,11 +109,11 @@ public class GrpcServerHealth {
}
}
class Cache {
static class Cache {
private final Map<String, Health> 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));
}

Loading…
Cancel
Save