From 03b0f4ecfe47caebe1de567e5f938da2b1571d3b Mon Sep 17 00:00:00 2001 From: Ryan Baxter Date: Tue, 3 Jun 2025 11:09:35 -0400 Subject: [PATCH] Fixing checkstyle --- .../GatewayMvcRuntimeHintsProcessor.java | 2 +- .../server/mvc/ServerMvcIntegrationTests.java | 35 +++++++++---------- .../mvc/config/TokenRelayConfigTests.java | 1 - 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/config/GatewayMvcRuntimeHintsProcessor.java b/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/config/GatewayMvcRuntimeHintsProcessor.java index 7dd037c6..d9075b4d 100644 --- a/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/config/GatewayMvcRuntimeHintsProcessor.java +++ b/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/config/GatewayMvcRuntimeHintsProcessor.java @@ -33,8 +33,8 @@ import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContrib import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions; import org.springframework.cloud.gateway.server.mvc.filter.FilterAutoConfiguration; +import org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions; import org.springframework.cloud.gateway.server.mvc.predicate.PredicateAutoConfiguration; import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; import org.springframework.core.type.filter.AssignableTypeFilter; diff --git a/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/ServerMvcIntegrationTests.java b/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/ServerMvcIntegrationTests.java index 7cf533cf..2332d5ca 100644 --- a/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/ServerMvcIntegrationTests.java +++ b/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/ServerMvcIntegrationTests.java @@ -40,7 +40,6 @@ import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; import jakarta.servlet.http.HttpServletRequest; import org.assertj.core.api.Assertions; -import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -154,9 +153,6 @@ import static org.springframework.web.servlet.function.RequestPredicates.path; @ExtendWith(OutputCaptureExtension.class) public class ServerMvcIntegrationTests { - public static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType(APPLICATION_FORM_URLENCODED, - StandardCharsets.UTF_8); - static { // if set type to autodetect above System.setProperty("sun.net.http.allowRestrictedHeaders", "true"); @@ -171,12 +167,6 @@ public class ServerMvcIntegrationTests { @Autowired TestRestClient restClient; - private static boolean isPNG(byte[] bytes) { - byte[] pngSignature = { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }; - byte[] header = Arrays.copyOf(bytes, pngSignature.length); - return Arrays.equals(pngSignature, header); - } - @Test public void nonGatewayRouterFunctionWorks() { restClient.get().uri("/hello").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("Hello"); @@ -603,6 +593,9 @@ public class ServerMvcIntegrationTests { .isOk(); } + private static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType(APPLICATION_FORM_URLENCODED, + StandardCharsets.UTF_8); + @Test void formUrlencodedWorks() { LinkedMultiValueMap formData = new LinkedMultiValueMap<>(); @@ -683,6 +676,12 @@ public class ServerMvcIntegrationTests { } } + private static boolean isPNG(byte[] bytes) { + byte[] pngSignature = { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }; + byte[] header = Arrays.copyOf(bytes, pngSignature.length); + return Arrays.equals(pngSignature, header); + } + @Test public void removeRequestHeaderWorks() { restClient.get() @@ -1056,10 +1055,10 @@ public class ServerMvcIntegrationTests { @Bean @Lazy @Override - public @NotNull HandlerMappingIntrospector mvcHandlerMappingIntrospector() { + public HandlerMappingIntrospector mvcHandlerMappingIntrospector() { return new HandlerMappingIntrospector() { @Override - public @NotNull Filter createCacheFilter() { + public Filter createCacheFilter() { return (request, response, chain) -> { chain.doFilter(request, response); }; @@ -1691,12 +1690,6 @@ public class ServerMvcIntegrationTests { private static class MyFilter implements Filter, Ordered { - static boolean isFormPost(HttpServletRequest request) { - String contentType = request.getContentType(); - return (contentType != null && contentType.contains(MediaType.APPLICATION_FORM_URLENCODED_VALUE) - && HttpMethod.POST.matches(request.getMethod())); - } - @Override public int getOrder() { return FormFilter.FORM_FILTER_ORDER - 1; @@ -1719,6 +1712,12 @@ public class ServerMvcIntegrationTests { } } + static boolean isFormPost(HttpServletRequest request) { + String contentType = request.getContentType(); + return (contentType != null && contentType.contains(MediaType.APPLICATION_FORM_URLENCODED_VALUE) + && HttpMethod.POST.matches(request.getMethod())); + } + } protected record Hello(String message) { diff --git a/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/config/TokenRelayConfigTests.java b/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/config/TokenRelayConfigTests.java index 86e8c222..ee293289 100644 --- a/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/config/TokenRelayConfigTests.java +++ b/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/config/TokenRelayConfigTests.java @@ -27,7 +27,6 @@ import org.springframework.cloud.gateway.server.mvc.test.HttpbinTestcontainers; import org.springframework.cloud.gateway.server.mvc.test.TestAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; -import org.springframework.http.HttpHeaders; import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager; import org.springframework.security.oauth2.core.OAuth2AccessToken;