10000 Polishing · spring-projects/spring-framework@3c84863 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c84863

Browse files
committed
Polishing
1 parent c2f6a98 commit 3c84863

File tree

7 files changed

+33
-35
lines changed

7 files changed

+33
-35
lines changed

spring-core/src/main/java/org/springframework/core/codec/StringDecoder.java

Lines changed: 2 additions & 8 deletions
D7AE
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public Charset getDefaultCharset() {
103103
return this.defaultCharset;
104104
}
105105

106+
106107
@Override
107108
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType) {
108109
return (elementType.resolve() == String.class && super.canDecode(elementType, mimeType));
@@ -167,7 +168,6 @@ private Charset getCharset(@Nullable MimeType mimeType) {
167168

168169
/**
169170
* Finds the first match and longest delimiter, {@link EndFrameBuffer} just after it.
170-
*
171171
* @param dataBuffer the buffer to find delimiters in
172172
* @param matcher used to find the first delimiters
173173
* @return a flux of buffers, containing {@link EndFrameBuffer} after each delimiter that was
@@ -221,16 +221,13 @@ private static DataBuffer joinAndStrip(List<DataBuffer> dataBuffers, boolean str
221221
}
222222

223223
DataBuffer result = dataBuffers.get(0).factory().join(dataBuffers);
224-
225224
if (stripDelimiter && matchingDelimiter != null) {
226225
result.writePosition(result.writePosition() - matchingDelimiter.length);
227226
}
228227
return result;
229228
}
230229

231230

232-
233-
234231
/**
235232
* Create a {@code StringDecoder} for {@code "text/plain"}.
236233
* @param stripDelimiter this flag is ignored
@@ -293,8 +290,7 @@ private static class EndFrameBuffer extends DataBufferWrapper {
293290

294291
private static final DataBuffer BUFFER = new DefaultDataBufferFactory().wrap(new byte[0]);
295292

296-
private byte[] delimiter;
297-
293+
private final byte[] delimiter;
298294

299295
public EndFrameBuffer(byte[] delimiter) {
300296
super(BUFFER);
@@ -304,7 +300,6 @@ public EndFrameBuffer(byte[] delimiter) {
304300
public byte[] delimiter() {
305301
return this.delimiter;
306302
}
307-
308303
}
309304

310305

@@ -313,7 +308,6 @@ private static class LimitChecker implements Consumer<DataBuffer> {
313308
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
314309
private final LimitedDataBufferList list;
315310

316-
317311
LimitChecker(int maxInMemorySize) {
318312
this.list = new LimitedDataBufferList(maxInMemorySize);
319313
}

spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,9 +30,9 @@
3030
*/
3131
final class StringToBooleanConverter implements Converter<String, Boolean> {
3232

33-
private static final Set<String> trueValues = new HashSet<>(4);
33+
private static final Set<String> trueValues = new HashSet<>(8);
3434

35-
private static final Set<String> falseValues = new HashSet<>(4);
35+
private static final Set<String> falseValues = new HashSet<>(8);
3636

3737
static {
3838
trueValues.add("true");
@@ -46,6 +46,7 @@ final class StringToBooleanConverter implements Converter<String, Boolean> {
4646
falseValues.add("0");
4747
}
4848

49+
4950
@Override
5051
public Boolean convert(String source) {
5152
String value = source.trim();

spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import java.util.UUID;
2020

2121
import org.springframework.core.convert.converter.Converter;
22+
import org.springframework.lang.Nullable;
2223
import org.springframework.util.StringUtils;
2324

2425
/**
@@ -31,6 +32,7 @@
3132
final class StringToUUIDConverter implements Converter<String, UUID> {
3233

3334
@Override
35+
@Nullable
3436
public UUID convert(String source) {
3537
return (StringUtils.hasText(source) ? UUID.fromString(source.trim()) : null);
3638
}

spring-web/src/main/java/org/springframework/http/ContentDisposition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ public interface Builder {
556556

557557
private static class BuilderImpl implements Builder {
558558

559-
private String type;
559+
private final String type;
560560

561561
@Nullable
562562
private String name;

src/docs/asciidoc/core/core-aop-api.adoc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ The `MethodMatcher` interface is normally more important. The complete interface
103103
The `matches(Method, Class)` method is used to test whether this pointcut ever
104104
matches a given method on a target class. This evaluation can be performed when an AOP
105105
proxy is created to avoid the need for a test on every method invocation. If the
106-
two-argument `matches` method returns `true` for a given method, and the `isRuntime()` method
107-
for the MethodMatcher returns `true`, the three-argument matches method is invoked on
108-
every method invocation. This lets a pointcut look at the arguments passed to the
109-
method invocation immediately before the target advice starts.
106+
two-argument `matches` method returns `true` for a given method, and the `isRuntime()`
107+
method for the MethodMatcher returns `true`, the three-argument matches method is
108+
invoked on every method invocation. This lets a pointcut look at the arguments passed
109+
to the method invocation immediately before the target advice starts.
110110

111-
Most `MethodMatcher` implementations are static, meaning that their `isRuntime()` method returns `false`.
112-
In this case, the three-argument `matches` method is never invoked.
111+
Most `MethodMatcher` implementations are static, meaning that their `isRuntime()` method
112+
returns `false`. In this case, the three-argument `matches` method is never invoked.
113113

114114
TIP: If possible, try to make pointcuts static, allowing the AOP framework to cache the
115115
results of pointcut evaluation when an AOP proxy is created.
@@ -145,20 +145,20 @@ See the <<aop, previous chapter>> for a discussion of supported AspectJ pointcut
145145
[[aop-api-pointcuts-impls]]
146146
=== Convenience Pointcut Implementations
147147

148-
Spring provides several convenient pointcut implementations. You can use some of them directly.
149-
Others are intended to be subclassed in application-specific pointcuts.
148+
Spring provides several convenient pointcut implementations. You can use some of them
149+
directly; others are intended to be subclassed in application-specific pointcuts.
150150

151151

152152
[[aop-api-pointcuts-static]]
153153
==== Static Pointcuts
154154

155-
Static pointcuts are based on the method and the target class and cannot take into account the
156-
method's arguments. Static pointcuts suffice -- and are best -- for most usages.
157-
Spring can evaluate a static pointcut only once, when a method is first
158-
invoked. After that, there is no need to evaluate the pointcut again with each method
159-
invocation.
155+
Static pointcuts are based on the method and the target class and cannot take into account
156+
the method's arguments. Static pointcuts suffice -- and are best -- for most usages.
157+
Spring can evaluate a static pointcut only once, when a method is first invoked.
158+
After that, there is no need to evaluate the pointcut again with each method invocation.
160159

161-
The rest of this section describes some of the static pointcut implementations that are included with Spring.
160+
The rest of this section describes some of the static pointcut implementations that are
161+
included with Spring.
162162

163163
[[aop-api-pointcuts-regex]]
164164
===== Regular Expression Pointcuts
@@ -168,9 +168,9 @@ frameworks besides Spring make this possible.
168168
`org.springframework.aop.support.JdkRegexpMethodPointcut` is a generic regular
169169
expression pointcut that uses the regular expression support in the JDK.
170170

171-
With the `JdkRegexpMethodPointcut` class, you can provide a list of pattern strings. If
172-
any of these is a match, the pointcut evaluates to `true`. (So, the result is
173-
effectively the union of these pointcuts.)
171+
With the `JdkRegexpMethodPointcut` class, you can provide a list of pattern strings.
172+
If any of these is a match, the pointcut evaluates to `true`. (As a consequence,
173+
the resulting pointcut is effectively the union of the specified patterns.)
174174

175175
The following example shows how to use `JdkRegexpMethodPointcut`:
176176

src/docs/asciidoc/core/core-aop.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ join point, unless you specify otherwise, the order of execution is undefined. Y
16491649
control the order of execution by specifying precedence. This is done in the normal
16501650
Spring way by either implementing the `org.springframework.core.Ordered` interface in
16511651
the aspect class or annotating it with the `@Order` annotation. Given two aspects, the
1652-
aspect returning the lower value from `Ordered.getValue()` (or the annotation value) has
1652+
aspect returning the lower value from `Ordered.getOrder()` (or the annotation value) has
16531653
the higher precedence.
16541654

16551655
[NOTE]
@@ -2918,7 +2918,7 @@ an aspect weaving phase to your build script.
29182918
If you have chosen to use Spring AOP, you have a choice of @AspectJ or XML style.
29192919
There are various tradeoffs to consider.
29202920

2921-
The XML style may most familiar to existing Spring users, and it is backed by genuine
2921+
The XML style may be most familiar to existing Spring users, and it is backed by genuine
29222922
POJOs. When using AOP as a tool to configure enterprise services, XML can be a good
29232923
choice (a good test is whether you consider the pointcut expression to be a part of your
29242924
configuration that you might want to change independently). With the XML style, it is

src/docs/asciidoc/core/core-beans.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ information on using the `BeanFactory` instead of the `ApplicationContext,` see
4242

4343
In Spring, the objects that form the backbone of your application and that are managed
4444
by the Spring IoC container are called beans. A bean is an object that is
45-
instantiated, assembled, and otherwise managed by a Spring IoC container. Otherwise, a
45+
instantiated, assembled, and managed by a Spring IoC container. Otherwise, a
4646
bean is simply one of many objects in your application. Beans, and the dependencies
4747
among them, are reflected in the configuration metadata used by a container.
4848

@@ -2125,7 +2125,7 @@ startup, because it must satisfy the singleton's dependencies. The lazy-initiali
21252125
is injected into a singleton bean elsewhere that is not lazy-initialized.
21262126

21272127
You can also control lazy-initialization at the container level by using the
2128-
`default-lazy-init` attribute on the `<beans/>` element, a the following example shows:
2128+
`default-lazy-init` attribute on the `<beans/>` element, as the following example shows:
21292129

21302130
[source,xml,indent=0,subs="verbatim,quotes"]
21312131
----
@@ -4429,7 +4429,8 @@ which these `BeanFactoryPostProcessor` instances run by setting the `order` prop
44294429
However, you can only set this property if the `BeanFactoryPostProcessor` implements the
44304430
`Ordered` interface. If you write your own `BeanFactoryPostProcessor`, you should
44314431
consider implementing the `Ordered` interface, too. See the javadoc of the
4432-
{api-spring-framework}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`] and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces for more details.
4432+
{api-spring-framework}/beans/factory/config/BeanFactoryPostProcessor.html[`BeanFactoryPostProcessor`]
4433+
and {api-spring-framework}/core/Ordered.html[`Ordered`] interfaces for more details.
44334434

44344435
[NOTE]
44354436
====

0 commit comments

Comments
 (0)
0