From 3ba9d35e224ec2909d9ab6bedc6ed2b40e3f1e1c Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 19 Sep 2024 14:57:52 +0900 Subject: [PATCH] Polish Closes gh-33566 --- .../ROOT/pages/core/validation/beanvalidation.adoc | 2 +- .../beans/factory/support/AbstractBeanFactory.java | 2 +- .../context/support/AbstractApplicationContext.java | 2 +- .../invocation/reactive/ChannelSendOperator.java | 2 +- .../java/org/springframework/mock/web/MockCookie.java | 9 +++++---- .../http/client/reactive/JdkClientHttpConnector.java | 2 +- .../http/server/reactive/ChannelSendOperator.java | 2 +- .../request/RequestAttributesThreadLocalAccessor.java | 4 ++-- .../http/codec/json/Jackson2JsonDecoderTests.java | 2 +- .../web/util/ContentCachingRequestWrapperTests.java | 11 +---------- .../web/testfixture/servlet/MockCookie.java | 9 +++++---- .../web/servlet/view/AbstractUrlBasedView.java | 2 +- 12 files changed, 21 insertions(+), 28 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/core/validation/beanvalidation.adoc b/framework-docs/modules/ROOT/pages/core/validation/beanvalidation.adoc index 4e7c9201cf..5669545ba2 100644 --- a/framework-docs/modules/ROOT/pages/core/validation/beanvalidation.adoc +++ b/framework-docs/modules/ROOT/pages/core/validation/beanvalidation.adoc @@ -385,7 +385,7 @@ To customize the default message, you can add properties to xref:core/beans/context-introduction.adoc#context-functionality-messagesource[MessageSource] resource bundles using any of the above errors codes and message arguments. Note also that the message argument `"name"` is itself a `MessageSourceResolvable` with error codes -`"person.name"` and `"name"` and can customized too. For example: +`"person.name"` and `"name"` and can be customized too. For example: Properties:: + diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 9be203b5f5..eeaeb2ced5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -160,7 +160,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** Map from scope identifier String to corresponding Scope. */ private final Map scopes = new LinkedHashMap<>(8); - /** Application startup metrics. **/ + /** Application startup metrics. */ private ApplicationStartup applicationStartup = ApplicationStartup.DEFAULT; /** Map from bean name to merged RootBeanDefinition. */ diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java index 94d6a52da7..cf320c12ff 100644 --- a/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java +++ b/spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java @@ -234,7 +234,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader @Nullable private ApplicationEventMulticaster applicationEventMulticaster; - /** Application startup metrics. **/ + /** Application startup metrics. */ private ApplicationStartup applicationStartup = ApplicationStartup.DEFAULT; /** Statically specified listeners. */ diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/ChannelSendOperator.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/ChannelSendOperator.java index 40bd169340..e4300e097f 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/ChannelSendOperator.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/reactive/ChannelSendOperator.java @@ -107,7 +107,7 @@ class ChannelSendOperator extends Mono implements Scannable { * The write subscriber has subscribed, and cached signals have been * emitted to it; we're ready to switch to a simple pass-through mode * for all remaining signals. - **/ + */ READY_TO_WRITE } diff --git a/spring-test/src/main/java/org/springframework/mock/web/MockCookie.java b/spring-test/src/main/java/org/springframework/mock/web/MockCookie.java index e3589d7463..cfeeeb0bbe 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/MockCookie.java +++ b/spring-test/src/main/java/org/springframework/mock/web/MockCookie.java @@ -45,6 +45,7 @@ public class MockCookie extends Cookie { private static final String SAME_SITE = "SameSite"; private static final String EXPIRES = "Expires"; + private static final String PARTITIONED = "Partitioned"; @Nullable private ZonedDateTime expires; @@ -105,10 +106,10 @@ public class MockCookie extends Cookie { */ public void setPartitioned(boolean partitioned) { if (partitioned) { - setAttribute("Partitioned", ""); + setAttribute(PARTITIONED, ""); } else { - setAttribute("Partitioned", null); + setAttribute(PARTITIONED, null); } } @@ -118,7 +119,7 @@ public class MockCookie extends Cookie { * @see The Partitioned attribute spec */ public boolean isPartitioned() { - return getAttribute("Partitioned") != null; + return getAttribute(PARTITIONED) != null; } /** @@ -207,7 +208,7 @@ public class MockCookie extends Cookie { .append("Comment", getComment()) .append("Secure", getSecure()) .append("HttpOnly", isHttpOnly()) - .append("Partitioned", isPartitioned()) + .append(PARTITIONED, isPartitioned()) .append(SAME_SITE, getSameSite()) .append("Max-Age", getMaxAge()) .append(EXPIRES, getAttribute(EXPIRES)) diff --git a/spring-web/src/main/java/org/springframework/http/client/reactive/JdkClientHttpConnector.java b/spring-web/src/main/java/org/springframework/http/client/reactive/JdkClientHttpConnector.java index 7424104a17..5b6f08de10 100644 --- a/spring-web/src/main/java/org/springframework/http/client/reactive/JdkClientHttpConnector.java +++ b/spring-web/src/main/java/org/springframework/http/client/reactive/JdkClientHttpConnector.java @@ -51,7 +51,7 @@ public class JdkClientHttpConnector implements ClientHttpConnector { private DataBufferFactory bufferFactory = DefaultDataBufferFactory.sharedInstance; @Nullable - private Duration readTimeout = null; + private Duration readTimeout; /** diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java index e9aa4e13e7..e4bd057bad 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java @@ -99,7 +99,7 @@ public class ChannelSendOperator extends Mono implements Scannable { * The write subscriber has subscribed, and cached signals have been * emitted to it; we're ready to switch to a simple pass-through mode * for all remaining signals. - **/ + */ READY_TO_WRITE } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessor.java b/spring-web/src/main/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessor.java index abec7aa4d4..fcaf2b4549 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessor.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessor.java @@ -70,10 +70,10 @@ public class RequestAttributesThreadLocalAccessor implements ThreadLocalAccessor /** * ServletRequestAttributes that takes another instance, and makes a copy of the - * request attributes at present to provides extended read access during async + * request attributes at present to provide extended read access during async * handling when the DispatcherServlet has exited from the initial REQUEST dispatch * and marked the request {@link ServletRequestAttributes#requestCompleted()}. - *

Note that beyond access to request attributes, here is no attempt to support + *

Note that beyond access to request attributes, there is no attempt to support * setting or removing request attributes, nor to access session attributes after * the initial REQUEST dispatch has exited. */ diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java index 5991af5ebe..b0d35105bb 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java @@ -174,7 +174,7 @@ class Jackson2JsonDecoderTests extends AbstractDecoderTests } @Test - protected void decodeToFluxWithListElements() { + void decodeToFluxWithListElements() { Flux input = Flux.concat( stringBuffer("[{\"bar\":\"b1\",\"foo\":\"f1\"},{\"bar\":\"b2\",\"foo\":\"f2\"}]"), stringBuffer("[{\"bar\":\"b3\",\"foo\":\"f3\"},{\"bar\":\"b4\",\"foo\":\"f4\"}]")); diff --git a/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java b/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java index fe710e1695..8da7ba658b 100644 --- a/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java @@ -17,15 +17,12 @@ package org.springframework.web.util; import java.io.UnsupportedEncodingException; -import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.util.FastByteArrayOutputStream; -import org.springframework.util.ReflectionUtils; import org.springframework.web.testfixture.servlet.MockHttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; @@ -95,13 +92,7 @@ class ContentCachingRequestWrapperTests { @Test void shouldNotAllocateMoreThanCacheLimit() throws Exception { ContentCachingRequestWrapper wrapper = new ContentCachingRequestWrapper(createGetRequest("Hello World"), CONTENT_CACHE_LIMIT); - Field field = ReflectionUtils.findField(ContentCachingRequestWrapper.class, "cachedContent"); - ReflectionUtils.makeAccessible(field); - FastByteArrayOutputStream cachedContent = (FastByteArrayOutputStream) ReflectionUtils.getField(field, wrapper); - field = ReflectionUtils.findField(FastByteArrayOutputStream.class, "initialBlockSize"); - ReflectionUtils.makeAccessible(field); - int blockSize = (int) ReflectionUtils.getField(field, cachedContent); - assertThat(blockSize).isEqualTo(CONTENT_CACHE_LIMIT); + assertThat(wrapper).extracting("cachedContent.initialBlockSize").isEqualTo(CONTENT_CACHE_LIMIT); } diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockCookie.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockCookie.java index ea0353fb21..d10c457324 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockCookie.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/MockCookie.java @@ -45,6 +45,7 @@ public class MockCookie extends Cookie { private static final String SAME_SITE = "SameSite"; private static final String EXPIRES = "Expires"; + private static final String PARTITIONED = "Partitioned"; @Nullable private ZonedDateTime expires; @@ -105,10 +106,10 @@ public class MockCookie extends Cookie { */ public void setPartitioned(boolean partitioned) { if (partitioned) { - setAttribute("Partitioned", ""); + setAttribute(PARTITIONED, ""); } else { - setAttribute("Partitioned", null); + setAttribute(PARTITIONED, null); } } @@ -118,7 +119,7 @@ public class MockCookie extends Cookie { * @see The Partitioned attribute spec */ public boolean isPartitioned() { - return getAttribute("Partitioned") != null; + return getAttribute(PARTITIONED) != null; } /** @@ -202,7 +203,7 @@ public class MockCookie extends Cookie { .append("Comment", getComment()) .append("Secure", getSecure()) .append("HttpOnly", isHttpOnly()) - .append("Partitioned", isPartitioned()) + .append(PARTITIONED, isPartitioned()) .append(SAME_SITE, getSameSite()) .append("Max-Age", getMaxAge()) .append(EXPIRES, getAttribute(EXPIRES)) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractUrlBasedView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractUrlBasedView.java index ee5be60cb3..51d5e53706 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractUrlBasedView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractUrlBasedView.java @@ -23,7 +23,7 @@ import org.springframework.lang.Nullable; /** * Abstract base class for URL-based views. Provides a consistent way of - * holding the URL that a View wraps, in the form of an "url" bean property. + * holding the URL that a View wraps, in the form of a "url" bean property. * * @author Juergen Hoeller * @since 13.12.2003