Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2861fc6

Browse files
committed
Polishing
1 parent 6a207d0 commit 2861fc6

File tree

35 files changed

+108
-121
lines changed

35 files changed

+108
-121
lines changed

spring-context/src/main/java/org/springframework/context/annotation/ParserStrategyUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ abstract class ParserStrategyUtils {
5252
* @since 5.2
5353
*/
5454
@SuppressWarnings("unchecked")
55-
static <T> T instantiateClass(Class<?> clazz, Class<T> assignableTo,
56-
Environment environment, ResourceLoader resourceLoader,
57-
BeanDefinitionRegistry registry) {
55+
static <T> T instantiateClass(Class<?> clazz, Class<T> assignableTo, Environment environment,
56+
ResourceLoader resourceLoader, BeanDefinitionRegistry registry) {
5857

5958
Assert.notNull(clazz, "Class must not be null");
6059
Assert.isAssignable(assignableTo, clazz);

spring-core/src/main/java/org/springframework/core/io/buffer/DataBuffer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ default DataBuffer retainedSlice(int index, int length) {
358358
/**
359359
* Return this buffer's data a String using the specified charset. Default implementation
360360
* delegates to {@code toString(readPosition(), readableByteCount(), charset)}.
361-
*
362361
* @param charset the character set to use
363362
* @return a string representation of all this buffers data
364363
* @since 5.2
@@ -370,7 +369,6 @@ default String toString(Charset charset) {
370369

371370
/**
372371
* Return a part of this buffer's data as a String using the specified charset.
373-
*
374372
* @param index the index at which to start the string
375373
* @param length the number of bytes to use for the string
376374
* @param charset the charset to use

spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ public static Flux<DataBuffer> readAsynchronousFileChannel(
164164
* @return a Flux of data buffers read from the given channel
165165
* @since 5.2
166166
*/
167-
public static Flux<DataBuffer> read(Path path, DataBufferFactory bufferFactory, int bufferSize,
168-
OpenOption... options) {
167+
public static Flux<DataBuffer> read(
168+
Path path, DataBufferFactory bufferFactory, int bufferSize, OpenOption... options) {
169+
169170
Assert.notNull(path, "Path must not be null");
170171
Assert.notNull(bufferFactory, "BufferFactory must not be null");
171172
Assert.isTrue(bufferSize > 0, "'bufferSize' must be > 0");
@@ -538,8 +539,8 @@ public static Mono<DataBuffer> join(Publisher<? extends DataBuffer> dataBuffers)
538539
}
539540

540541
/**
541-
* Return a {@link Matcher} for the given delimiter. The matcher can be used to find the
542-
* delimiters in data buffers.
542+
* Return a {@link Matcher} for the given delimiter.
543+
* The matcher can be used to find the delimiters in data buffers.
543544
* @param delimiter the delimiter bytes to find
544545
* @return the matcher
545546
* @since 5.2
@@ -549,8 +550,8 @@ public static Matcher matcher(byte[] delimiter) {
549550
return new KnuthMorrisPrattMatcher(delimiter);
550551
}
551552

552-
/** Return a {@link Matcher} for the given delimiters. The matcher can be used to find the
553-
* delimiters in data buffers.
553+
/** Return a {@link Matcher} for the given delimiters.
554+
* The matcher can be used to find the delimiters in data buffers.
554555
* @param delimiters the delimiters bytes to find
555556
* @return the matcher
556557
* @since 5.2
@@ -595,7 +596,6 @@ public interface Matcher {
595596
* Resets the state of this matcher.
596597
*/
597598
void reset();
598-
599599
}
600600

601601

@@ -730,7 +730,6 @@ public void cancel() {
730730
private boolean isNotDisposed() {
731731
return !this.disposed.get();
732732
}
733-
734733
}
735734

736735

@@ -866,12 +865,11 @@ private void sinkDataBuffer() {
866865
this.sink.next(dataBuffer);
867866
this.dataBuffer.set(null);
868867
}
869-
870868
}
871869

870+
872871
/**
873872
* Implementation of {@link Matcher} that uses the Knuth-Morris-Pratt algorithm.
874-
*
875873
* @see <a href="https://www.nayuki.io/page/knuth-morris-pratt-string-matching">Knuth-Morris-Pratt string matching</a>
876874
*/
877875
private static class KnuthMorrisPrattMatcher implements Matcher {
@@ -882,7 +880,6 @@ private static class KnuthMorrisPrattMatcher implements Matcher {
882880

883881
private int matches = 0;
884882

885-
886883
public KnuthMorrisPrattMatcher(byte[] delimiter) {
887884
this.delimiter = Arrays.copyOf(delimiter, delimiter.length);
888885
this.table = longestSuffixPrefixTable(delimiter);
@@ -935,6 +932,7 @@ public void reset() {
935932
}
936933
}
937934

935+
938936
/**
939937
* Implementation of {@link Matcher} that wraps several other matchers.
940938
*/
@@ -946,7 +944,6 @@ private static class CompositeMatcher implements Matcher {
946944

947945
byte[] longestDelimiter = NO_DELIMITER;
948946

949-
950947
public CompositeMatcher(Matcher[] matchers) {
951948
this.matchers = matchers;
952949
}

spring-core/src/main/java/org/springframework/util/RouteMatcher.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public interface RouteMatcher {
4242
*/
4343
Route parseRoute(String routeValue);
4444

45-
4645
/**
4746
* Whether the given {@code route} contains pattern syntax which requires
4847
* the {@link #match(String, Route)} method, or if it is a regular String

spring-core/src/main/java/org/springframework/util/SimpleRouteMatcher.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.util;
1718

1819
import java.util.Comparator;
@@ -36,12 +37,18 @@ public class SimpleRouteMatcher implements RouteMatcher {
3637
private final PathMatcher pathMatcher;
3738

3839

40+
/**
41+
* Create a new {@code SimpleRouteMatcher} for the given
42+
* {@link PathMatcher} delegate.
43+
*/
3944
public SimpleRouteMatcher(PathMatcher pathMatcher) {
4045
Assert.notNull(pathMatcher, "PathMatcher is required");
4146
this.pathMatcher = pathMatcher;
4247
}
4348

44-
49+
/**
50+
* Return the underlying {@link PathMatcher} delegate.
51+
*/
4552
public PathMatcher getPathMatcher() {
4653
return this.pathMatcher;
4754
}
@@ -86,12 +93,10 @@ private static class DefaultRoute implements Route {
8693

8794
private final String path;
8895

89-
9096
DefaultRoute(String path) {
9197
this.path = path;
9298
}
9399

94-
95100
@Override
96101
public String value() {
97102
return this.path;

spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public abstract class ScriptUtils {
8585
* Default prefixes for single-line comments within SQL scripts: {@code ["--"]}.
8686
* @since 5.2
8787
*/
88-
public static final String[] DEFAULT_COMMENT_PREFIXES = { DEFAULT_COMMENT_PREFIX };
88+
public static final String[] DEFAULT_COMMENT_PREFIXES = {DEFAULT_COMMENT_PREFIX};
8989

9090
/**
9191
* Default start delimiter for block comments within SQL scripts: {@code "/*"}.
@@ -214,8 +214,8 @@ public static void splitSqlScript(@Nullable EncodedResource resource, String scr
214214
Assert.hasText(script, "'script' must not be null or empty");
215215
Assert.notNull(separator, "'separator' must not be null");
216216
Assert.notEmpty(commentPrefixes, "'commentPrefixes' must not be null or empty");
217-
for (int i = 0; i < commentPrefixes.length; i++) {
218-
Assert.hasText(commentPrefixes[i], "'commentPrefixes' must not contain null or empty elements");
217+
for (String commentPrefix : commentPrefixes) {
218+
Assert.hasText(commentPrefix, "'commentPrefixes' must not contain null or empty elements");
219219
}
220220
Assert.hasText(blockCommentStartDelimiter, "'blockCommentStartDelimiter' must not be null or empty");
221221
Assert.hasText(blockCommentEndDelimiter, "'blockCommentEndDelimiter' must not be null or empty");

spring-messaging/src/main/java/org/springframework/messaging/ReactiveMessageHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public interface ReactiveMessageHandler {
3131
/**
3232
* Handle the given message.
3333
* @param message the message to be handled
34-
* @return a completion {@link Mono} for the result of the message handling.
34+
* @return a completion {@link Mono} for the result of the message handling
3535
*/
3636
Mono<Void> handleMessage(Message<?> message);
3737

spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/ConnectMapping.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@
5555
* Mappings expressed by this annotation to match to the route from the
5656
* metadata of the initial {@link ConnectionSetupPayload} or in
5757
* subsequent metadata pushes.
58-
*
5958
* <p>Depending on the configured
6059
* {@link org.springframework.util.RouteMatcher RouteMatcher}, the pattern may be
6160
* {@link org.springframework.util.AntPathMatcher AntPathMatcher} or
6261
* {@link org.springframework.web.util.pattern.PathPattern PathPattern} based.
63-
*
6462
* <p>By default this is an empty array in which case it matches all
6563
* {@link ConnectionSetupPayload} and metadata pushes.
6664
*/

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,6 @@ private class DefaultStats implements Stats {
10531053

10541054
private final AtomicInteger disconnect = new AtomicInteger();
10551055

1056-
10571056
public void incrementConnectCount() {
10581057
this.connect.incrementAndGet();
10591058
}

spring-tx/src/main/java/org/springframework/transaction/reactive/TransactionSynchronizationManager.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ public Object getResource(Object key) {
125125
*/
126126
@Nullable
127127
private Object doGetResource(Object actualKey) {
128-
Map<Object, Object> map = this.transactionContext.getResources();
129-
Object value = map.get(actualKey);
130-
return value;
128+
return this.transactionContext.getResources().get(actualKey);
131129
}
132130

133131
/**

spring-web/src/main/java/org/springframework/http/client/MultipartBodyBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ public PartBuilder part(String name, Object part, @Nullable MediaType contentTyp
171171
* @param elementClass the type of elements contained in the publisher
172172
* @return builder that allows for further customization of part headers
173173
*/
174-
@SuppressWarnings("unchecked")
175174
public <T, P extends Publisher<T>> PartBuilder asyncPart(String name, P publisher, Class<T> elementClass) {
176175
Assert.hasLength(name, "'name' must not be empty");
177176
Assert.notNull(publisher, "'publisher' must not be null");

spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpConnector.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,6 @@ public JettyClientHttpConnector() {
5353
this(new HttpClient());
5454
}
5555

56-
/**
57-
* Constructor with an {@link JettyResourceFactory} that will manage shared resources.
58-
* @param resourceFactory the {@link JettyResourceFactory} to use
59-
* @param customizer the lambda used to customize the {@link HttpClient}
60-
* @deprecated as of 5.2, in favor of {@link JettyClientHttpConnector#JettyClientHttpConnector(HttpClient, JettyResourceFactory)}
61-
*/
62-
@Deprecated
63-
public JettyClientHttpConnector(
64-
JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
65-
this(new HttpClient(), resourceFactory);
66-
if (customizer != null) {
67-
customizer.accept(this.httpClient);
68-
}
69-
}
70-
7156
/**
7257
* Constructor with an initialized {@link HttpClient}.
7358
*/
@@ -82,8 +67,7 @@ public JettyClientHttpConnector(HttpClient httpClient) {
8267
* @param resourceFactory the {@link JettyResourceFactory} to use
8368
* @since 5.2
8469
*/
85-
public JettyClientHttpConnector(HttpClient httpClient,
86-
@Nullable JettyResourceFactory resourceFactory) {
70+
public JettyClientHttpConnector(HttpClient httpClient, @Nullable JettyResourceFactory resourceFactory) {
8771
Assert.notNull(httpClient, "HttpClient is required");
8872
if (resourceFactory != null) {
8973
httpClient.setExecutor(resourceFactory.getExecutor());
@@ -93,6 +77,20 @@ public JettyClientHttpConnector(HttpClient httpClient,
9377
this.httpClient = httpClient;
9478
}
9579

80+
/**
81+
* Constructor with an {@link JettyResourceFactory} that will manage shared resources.
82+
* @param resourceFactory the {@link JettyResourceFactory} to use
83+
* @param customizer the lambda used to customize the {@link HttpClient}
84+
* @deprecated as of 5.2, in favor of {@link JettyClientHttpConnector#JettyClientHttpConnector(HttpClient, JettyResourceFactory)}
85+
*/
86+
@Deprecated
87+
public JettyClientHttpConnector(JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
88+
this(new HttpClient(), resourceFactory);
89+
if (customizer != null) {
90+
customizer.accept(this.httpClient);
91+
}
92+
}
93+
9694

9795
public void setBufferFactory(DataBufferFactory bufferFactory) {
9896
this.bufferFactory = bufferFactory;

spring-web/src/main/java/org/springframework/http/client/support/HttpAccessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ protected ClientHttpRequest createRequest(URI url, HttpMethod method) throws IOE
130130
}
131131

132132
private void initialize(ClientHttpRequest request) {
133-
this.clientHttpRequestInitializers.forEach(
134-
initializer -> initializer.initialize(request));
133+
this.clientHttpRequestInitializers.forEach(initializer -> initializer.initialize(request));
135134
}
136135

137136
}

spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborDecoder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ public Jackson2CborDecoder(ObjectMapper mapper, MimeType... mimeTypes) {
5151
Assert.isAssignable(CBORFactory.class, mapper.getFactory().getClass());
5252
}
5353

54+
5455
@Override
5556
public Flux<Object> decode(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
5657
throw new UnsupportedOperationException("Does not support stream decoding yet");
5758
}
59+
5860
}

spring-web/src/main/java/org/springframework/http/codec/cbor/Jackson2CborEncoder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ public Jackson2CborEncoder(ObjectMapper mapper, MimeType... mimeTypes) {
5252
Assert.isAssignable(CBORFactory.class, mapper.getFactory().getClass());
5353
}
5454

55+
5556
@Override
5657
public Flux<DataBuffer> encode(Publisher<?> inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) {
5758
throw new UnsupportedOperationException("Does not support stream encoding yet");
5859
}
60+
5961
}

spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,18 @@ public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
203203
* Add {@link MediaType} objects to be supported by this converter.
204204
* <p>The supplied {@code MediaType} objects will be appended to the list
205205
* of {@linkplain #getSupportedMediaTypes() supported MediaType objects}.
206-
* @param supportedMediaTypes a var-args list of {@code MediaType} objects
207-
* to add
206+
* @param supportedMediaTypes a var-args list of {@code MediaType} objects to add
208207
* @since 5.2
209208
* @see #setSupportedMediaTypes(List)
210209
*/
211210
public void addSupportedMediaTypes(MediaType... supportedMediaTypes) {
212211
Assert.notNull(supportedMediaTypes, "'supportedMediaTypes' must not be null");
213212
Assert.noNullElements(supportedMediaTypes, "'supportedMediaTypes' must not contain null elements");
214-
for (MediaType mediaType : supportedMediaTypes) {
215-
this.supportedMediaTypes.add(mediaType);
216-
}
213+
Collections.addAll(this.supportedMediaTypes, supportedMediaTypes);
217214
}
218215

219216
/**
220217
* {@inheritDoc}
221-
*
222218
* @see #setSupportedMediaTypes(List)
223219
* @see #addSupportedMediaTypes(MediaType...)
224220
*/

spring-web/src/main/java/org/springframework/http/server/PathContainer.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,15 @@ class Options {
148148
*/
149149
public final static Options MESSAGE_ROUTE = Options.create('.', false);
150150

151-
152151
private final char separator;
153152

154153
private final boolean decodeAndParseSegments;
155154

156-
157155
private Options(char separator, boolean decodeAndParseSegments) {
158156
this.separator = separator;
159157
this.decodeAndParseSegments = decodeAndParseSegments;
160158
}
161159

162-
163160
public char separator() {
164161
return this.separator;
165162
}
@@ -168,7 +165,6 @@ public boolean shouldDecodeAndParseSegments() {
168165
return this.decodeAndParseSegments;
169166
}
170167

171-
172168
/**
173169
* Create an {@link Options} instance with the given settings.
174170
* @param separator the separator for parsing the path into segments;

spring-web/src/main/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.web.filter.reactive;
1718

1819
import java.util.Optional;

0 commit comments

Comments
 (0)