diff --git a/.editorconfig b/.editorconfig index 3e1127a6d670..4feb8079a18a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,10 +1,10 @@ root = true -[*.{adoc,bat,groovy,html,java,js,jsp,kt,kts,md,properties,py,rb,sh,sql,svg,txt,xml,xsd}] +[*] charset = utf-8 +end_of_line = lf [*.{groovy,java,kt,kts,xml,xsd}] indent_style = tab indent_size = 4 continuation_indent_size = 8 -end_of_line = lf diff --git a/buildSrc/config/checkstyle/checkstyle.xml b/buildSrc/config/checkstyle/checkstyle.xml index b75fed0d6583..a58ebe3fe653 100644 --- a/buildSrc/config/checkstyle/checkstyle.xml +++ b/buildSrc/config/checkstyle/checkstyle.xml @@ -1,7 +1,7 @@ - + - @@ -10,17 +10,17 @@ - - - + + + + - diff --git a/integration-tests/src/test/java/org/springframework/aot/test/ReflectionInvocationsTests.java b/integration-tests/src/test/java/org/springframework/aot/test/ReflectionInvocationsTests.java index 1a1123c22670..ca90f1e8430a 100644 --- a/integration-tests/src/test/java/org/springframework/aot/test/ReflectionInvocationsTests.java +++ b/integration-tests/src/test/java/org/springframework/aot/test/ReflectionInvocationsTests.java @@ -20,7 +20,7 @@ import org.springframework.aot.hint.RuntimeHints; import org.springframework.aot.test.agent.EnabledIfRuntimeHintsAgent; -import org.springframework.aot.test.agent.RuntimeHintsInvocations; +import org.springframework.aot.test.agent.RuntimeHintsRecorder; import static org.assertj.core.api.Assertions.assertThat; @@ -34,11 +34,10 @@ void sampleTest() { RuntimeHints hints = new RuntimeHints(); hints.reflection().registerType(String.class); - RuntimeHintsInvocations invocations = org.springframework.aot.test.agent.RuntimeHintsRecorder.record(() -> { + assertThat(RuntimeHintsRecorder.record(() -> { SampleReflection sample = new SampleReflection(); - sample.sample(); // does Method[] methods = String.class.getMethods(); - }); - assertThat(invocations).match(hints); + sample.sample(); // String.class.getMethods(); + })).match(hints); } @Test @@ -46,11 +45,11 @@ void multipleCallsTest() { RuntimeHints hints = new RuntimeHints(); hints.reflection().registerType(String.class); hints.reflection().registerType(Integer.class); - RuntimeHintsInvocations invocations = org.springframework.aot.test.agent.RuntimeHintsRecorder.record(() -> { + + assertThat(RuntimeHintsRecorder.record(() -> { SampleReflection sample = new SampleReflection(); - sample.multipleCalls(); // does Method[] methods = String.class.getMethods(); methods = Integer.class.getMethods(); - }); - assertThat(invocations).match(hints); + sample.multipleCalls(); // String.class.getMethods(); Integer.class.getMethods(); + })).match(hints); } } diff --git a/integration-tests/src/test/java/org/springframework/aot/test/SampleReflection.java b/integration-tests/src/test/java/org/springframework/aot/test/SampleReflection.java index 3f8cbadffc61..bd4779ccd474 100644 --- a/integration-tests/src/test/java/org/springframework/aot/test/SampleReflection.java +++ b/integration-tests/src/test/java/org/springframework/aot/test/SampleReflection.java @@ -16,25 +16,19 @@ package org.springframework.aot.test; -import java.lang.reflect.Method; - /** * @author Brian Clozel * @since 6.0 */ public class SampleReflection { - @SuppressWarnings("unused") public void sample() { - String value = "Sample"; - Method[] methods = String.class.getMethods(); + String.class.getMethods(); } - @SuppressWarnings("unused") public void multipleCalls() { - String value = "Sample"; - Method[] methods = String.class.getMethods(); - methods = Integer.class.getMethods(); +// String.class.getMethods(); + Integer.class.getMethods(); } } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java index 45956f2c1f0b..7443cd93d83d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java @@ -123,16 +123,11 @@ void testStringArgGetter() throws Exception { .addPropertyValue("serviceLocatorInterface", TestServiceLocator2.class) .getBeanDefinition()); - // test string-arg getter with null id - TestServiceLocator2 factory = (TestServiceLocator2) bf.getBean("factory"); - - @SuppressWarnings("unused") - TestService testBean = factory.getTestService(null); - // now test with explicit id - testBean = factory.getTestService("testService"); - // now verify failure on bad id - assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> - factory.getTestService("bogusTestService")); + final var factory = (TestServiceLocator2) bf.getBean("factory"); // test string-arg getter + factory.getTestService(null); // with null id + factory.getTestService("testService"); // test with explicit id + assertThatExceptionOfType(NoSuchBeanDefinitionException.class) + .isThrownBy(() -> factory.getTestService("bogusTestService")); // verify failure on bad id } @Disabled @Test // worked when using an ApplicationContext (see commented), fails when using BeanFactory @@ -145,14 +140,6 @@ public void testCombinedLocatorInterface() { .addPropertyValue("serviceLocatorInterface", TestServiceLocator3.class) .getBeanDefinition()); -// StaticApplicationContext ctx = new StaticApplicationContext(); -// ctx.registerPrototype("testService", TestService.class, new MutablePropertyValues()); -// ctx.registerAlias("testService", "1"); -// MutablePropertyValues mpv = new MutablePropertyValues(); -// mpv.addPropertyValue("serviceLocatorInterface", TestServiceLocator3.class); -// ctx.registerSingleton("factory", ServiceLocatorFactoryBean.class, mpv); -// ctx.refresh(); - TestServiceLocator3 factory = (TestServiceLocator3) bf.getBean("factory"); TestService testBean1 = factory.getTestService(); TestService testBean2 = factory.getTestService("testService"); @@ -177,16 +164,6 @@ public void testServiceMappings() { .addPropertyValue("serviceLocatorInterface", TestServiceLocator3.class) .addPropertyValue("serviceMappings", "=testService1\n1=testService1\n2=testService2") .getBeanDefinition()); - -// StaticApplicationContext ctx = new StaticApplicationContext(); -// ctx.registerPrototype("testService1", TestService.class, new MutablePropertyValues()); -// ctx.registerPrototype("testService2", ExtendedTestService.class, new MutablePropertyValues()); -// MutablePropertyValues mpv = new MutablePropertyValues(); -// mpv.addPropertyValue("serviceLocatorInterface", TestServiceLocator3.class); -// mpv.addPropertyValue("serviceMappings", "=testService1\n1=testService1\n2=testService2"); -// ctx.registerSingleton("factory", ServiceLocatorFactoryBean.class, mpv); -// ctx.refresh(); - TestServiceLocator3 factory = (TestServiceLocator3) bf.getBean("factory"); TestService testBean1 = factory.getTestService(); TestService testBean2 = factory.getTestService("testService1"); @@ -303,8 +280,6 @@ public interface TestService2Locator { public interface ServiceLocatorInterfaceWithExtraNonCompliantMethod { - TestService2 getTestService(); - TestService2 getTestService(String serviceName, String defaultNotAllowedParameter); } diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java index 0bae62c0dc84..c0bab0b5f512 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java @@ -7145,8 +7145,7 @@ public TestClass9(int i) { static class HttpServlet3RequestFactory { static Servlet3SecurityContextHolderAwareRequestWrapper getOne() { - HttpServlet3RequestFactory outer = new HttpServlet3RequestFactory(); - return outer.new Servlet3SecurityContextHolderAwareRequestWrapper(); + return new HttpServlet3RequestFactory().new Servlet3SecurityContextHolderAwareRequestWrapper(); } // private class Servlet3SecurityContextHolderAwareRequestWrapper extends SecurityContextHolderAwareRequestWrapper diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java index 82c1d5a0dc42..150c7844c295 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java @@ -70,10 +70,9 @@ public void performGet() { String responseBody = "{\"name\" : \"Ludwig van Beethoven\", \"someDouble\" : \"1.6035\"}"; this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) - .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); + .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); - @SuppressWarnings("unused") - Person ludwig = this.restTemplate.getForObject("/composers/{id}", Person.class, 42); + this.restTemplate.getForObject("/composers/{id}", Person.class, 42); // We are only validating the request. The response is mocked out. // hotel.getId() == 42 @@ -90,8 +89,7 @@ public void performGetManyTimes() { this.mockServer.expect(manyTimes(), requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); - @SuppressWarnings("unused") - Person ludwig = this.restTemplate.getForObject("/composers/{id}", Person.class, 42); + this.restTemplate.getForObject("/composers/{id}", Person.class, 42); // We are only validating the request. The response is mocked out. // hotel.getId() == 42 @@ -142,8 +140,7 @@ public void performGetWithResponseBodyFromFile() { this.mockServer.expect(requestTo("/composers/42")).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON)); - @SuppressWarnings("unused") - Person ludwig = this.restTemplate.getForObject("/composers/{id}", Person.class, 42); + this.restTemplate.getForObject("/composers/{id}", Person.class, 42); // hotel.getId() == 42 // hotel.getName().equals("Holiday Inn") @@ -155,16 +152,16 @@ public void performGetWithResponseBodyFromFile() { public void verify() { this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) - .andRespond(withSuccess("1", MediaType.TEXT_PLAIN)); + .andRespond(withSuccess("1", MediaType.TEXT_PLAIN)); this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) - .andRespond(withSuccess("2", MediaType.TEXT_PLAIN)); + .andRespond(withSuccess("2", MediaType.TEXT_PLAIN)); this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) - .andRespond(withSuccess("4", MediaType.TEXT_PLAIN)); + .andRespond(withSuccess("4", MediaType.TEXT_PLAIN)); this.mockServer.expect(requestTo("/number")).andExpect(method(HttpMethod.GET)) - .andRespond(withSuccess("8", MediaType.TEXT_PLAIN)); + .andRespond(withSuccess("8", MediaType.TEXT_PLAIN)); @SuppressWarnings("unused") String result1 = this.restTemplate.getForObject("/number", String.class); @@ -215,7 +212,7 @@ private ContentInterceptor(Resource resource) { @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, - ClientHttpRequestExecution execution) throws IOException { + ClientHttpRequestExecution execution) throws IOException { ClientHttpResponse response = execution.execute(request, body); byte[] expected = FileCopyUtils.copyToByteArray(this.resource.getInputStream()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java index 9e3b3cf41511..5fb59a0370c0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java @@ -289,7 +289,7 @@ void getCorsConfigWithBeanNameHandler() throws Exception { this.mapping.setApplicationContext(context); this.mapping.registerMapping(key, beanName, this.method1); - HandlerMethod handlerMethod = this.mapping.getHandlerInternal(new MockHttpServletRequest("GET", key)); + this.mapping.getHandlerInternal(new MockHttpServletRequest("GET", key)); } @Test diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index eb8c068dd409..795c4470e71d 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -1,12 +1,10 @@ - - @@ -15,11 +13,13 @@ - - + - + + + + @@ -27,7 +27,6 @@ - @@ -38,7 +37,6 @@ - @@ -48,7 +46,6 @@ - @@ -56,10 +53,8 @@ - - @@ -74,7 +69,6 @@ - @@ -87,11 +81,7 @@ - - - - @@ -131,7 +121,6 @@ - @@ -159,14 +148,11 @@ - - - @@ -175,7 +161,6 @@ - @@ -256,7 +241,6 @@ - @@ -264,7 +248,9 @@ - + + + + - diff --git a/src/nohttp/checkstyle.xml b/src/nohttp/checkstyle.xml index f968de4fc528..85186bd76a1a 100644 --- a/src/nohttp/checkstyle.xml +++ b/src/nohttp/checkstyle.xml @@ -3,7 +3,6 @@ - @@ -13,4 +12,14 @@ - \ No newline at end of file + + + + + + + + + + +