Skip to content

Commit 8dd285f

Browse files
committed
Polishing
1 parent 94eee6a commit 8dd285f

File tree

13 files changed

+68
-61
lines changed

13 files changed

+68
-61
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@
9696
* operating on pre-resolved bean definition metadata objects.
9797
*
9898
* <p>Note that readers for specific bean definition formats are typically
99-
* implemented separately rather than as bean factory subclasses:
100-
* see for example {@link PropertiesBeanDefinitionReader} and
99+
* implemented separately rather than as bean factory subclasses: see for example
101100
* {@link org.springframework.beans.factory.xml.XmlBeanDefinitionReader}.
102101
*
103102
* <p>For an alternative implementation of the
@@ -184,7 +183,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
184183
private volatile String[] frozenBeanDefinitionNames;
185184

186185
/** Whether bean definition metadata may be cached for all beans. */
187-
private volatile boolean configurationFrozen = false;
186+
private volatile boolean configurationFrozen;
188187

189188

190189
/**
@@ -355,12 +354,11 @@ public <T> T getBean(Class<T> requiredType, @Nullable Object... args) throws Bea
355354
}
356355

357356
@Override
358-
public <T> ObjectProvider<T> getBeanProvider(Class<T> requiredType) throws BeansException {
357+
public <T> ObjectProvider<T> getBeanProvider(Class<T> requiredType) {
359358
Assert.notNull(requiredType, "Required type must not be null");
360359
return getBeanProvider(ResolvableType.forRawClass(requiredType));
361360
}
362361

363-
@SuppressWarnings("unchecked")
364362
@Override
365363
public <T> ObjectProvider<T> getBeanProvider(ResolvableType requiredType) {
366364
return new BeanObjectProvider<T>() {
@@ -390,12 +388,14 @@ public T getIfAvailable() throws BeansException {
390388
public T getIfUnique() throws BeansException {
391389
return resolveBean(requiredType, null, true);
392390
}
391+
@SuppressWarnings("unchecked")
393392
@Override
394393
public Stream<T> stream() {
395394
return Arrays.stream(getBeanNamesForTypedStream(requiredType))
396395
.map(name -> (T) getBean(name))
397396
.filter(bean -> !(bean instanceof NullBean));
398397
}
398+
@SuppressWarnings("unchecked")
399399
@Override
400400
public Stream<T> orderedStream() {
401401
String[] beanNames = getBeanNamesForTypedStream(requiredType);

spring-context/src/main/java/org/springframework/cache/support/AbstractValueAdaptingCache.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 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.
@@ -55,8 +55,7 @@ public final boolean isAllowNullValues() {
5555
@Override
5656
@Nullable
5757
public ValueWrapper get(Object key) {
58-
Object value = lookup(key);
59-
return toValueWrapper(value);
58+
return toValueWrapper(lookup(key));
6059
}
6160

6261
@Override
@@ -123,5 +122,4 @@ protected Cache.ValueWrapper toValueWrapper(@Nullable Object storeValue) {
123122
return (storeValue != null ? new SimpleValueWrapper(fromStoreValue(storeValue)) : null);
124123
}
125124

126-
127125
}

spring-core/src/main/java/org/springframework/core/io/FileUrlResource.java

Lines changed: 2 additions & 2 deletions
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.
@@ -52,7 +52,7 @@ public class FileUrlResource extends UrlResource implements WritableResource {
5252
/**
5353
* Create a new {@code FileUrlResource} based on the given URL object.
5454
* <p>Note that this does not enforce "file" as URL protocol. If a protocol
55-
* is known to be resolvable to a file,
55+
* is known to be resolvable to a file, it is acceptable for this purpose.
5656
* @param url a URL
5757
* @see ResourceUtils#isFileURL(URL)
5858
* @see #getFile()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ private static class ConcurrentLruCache<K, V> {
428428

429429
private final Function<K, V> generator;
430430

431-
private volatile int size = 0;
431+
private volatile int size;
432432

433433
public ConcurrentLruCache(int maxSize, Function<K, V> generator) {
434434
Assert.isTrue(maxSize > 0, "LRU max size should be positive");

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

Lines changed: 2 additions & 2 deletions
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.
@@ -60,7 +60,7 @@ public Mono<Object> resolveArgument(MethodParameter parameter, Message<?> messag
6060
return Mono.just(requester);
6161
}
6262
else if (RSocket.class.isAssignableFrom(type)) {
63-
return Mono.just(requester.rsocket());
63+
return Mono.justOrEmpty(requester.rsocket());
6464
}
6565
else {
6666
return Mono.error(new IllegalArgumentException("Unexpected parameter type: " + parameter));

spring-tx/src/main/java/org/springframework/dao/support/PersistenceExceptionTranslationInterceptor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ public Object invoke(MethodInvocation mi) throws Throwable {
146146
else {
147147
PersistenceExceptionTranslator translator = this.persistenceExceptionTranslator;
148148
if (translator == null) {
149-
Assert.state(this.beanFactory != null, "Cannot use PersistenceExceptionTranslator autodetection without ListableBeanFactory");
149+
Assert.state(this.beanFactory != null,
150+
"Cannot use PersistenceExceptionTranslator autodetection without ListableBeanFactory");
150151
translator = detectPersistenceExceptionTranslators(this.beanFactory);
151152
this.persistenceExceptionTranslator = translator;
152153
}
@@ -157,16 +158,15 @@ public Object invoke(MethodInvocation mi) throws Throwable {
157158

158159
/**
159160
* Detect all PersistenceExceptionTranslators in the given BeanFactory.
160-
* @param beanFactory the ListableBeanFactory to obtaining all
161-
* PersistenceExceptionTranslators from
161+
* @param bf the ListableBeanFactory to obtain PersistenceExceptionTranslators from
162162
* @return a chained PersistenceExceptionTranslator, combining all
163-
* PersistenceExceptionTranslators found in the factory
163+
* PersistenceExceptionTranslators found in the given bean factory
164164
* @see ChainedPersistenceExceptionTranslator
165165
*/
166-
protected PersistenceExceptionTranslator detectPersistenceExceptionTranslators(ListableBeanFactory beanFactory) {
166+
protected PersistenceExceptionTranslator detectPersistenceExceptionTranslators(ListableBeanFactory bf) {
167167
// Find all translators, being careful not to activate FactoryBeans.
168168
Map<String, PersistenceExceptionTranslator> pets = BeanFactoryUtils.beansOfTypeIncludingAncestors(
169-
beanFactory, PersistenceExceptionTranslator.class, false, false);
169+
bf, PersistenceExceptionTranslator.class, false, false);
170170
ChainedPersistenceExceptionTranslator cpet = new ChainedPersistenceExceptionTranslator();
171171
for (PersistenceExceptionTranslator pet : pets.values()) {
172172
cpet.addDelegate(pet);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
* @see <a href="https://tools.ietf.org/html/rfc7231#section-3.1.1.1">
5050
* HTTP 1.1: Semantics and Content, section 3.1.1.1</a>
5151
*/
52-
@SuppressWarnings("deprecation")
5352
public class MediaType extends MimeType implements Serializable {
5453

5554
private static final long serialVersionUID = 2069937152339670231L;
@@ -647,7 +646,7 @@ else if (mediaTypes.size() == 1) {
647646
*/
648647
public static List<MediaType> asMediaTypes(List<MimeType> mimeTypes) {
649648
List<MediaType> mediaTypes = new ArrayList<>(mimeTypes.size());
650-
for(MimeType mimeType : mimeTypes) {
649+
for (MimeType mimeType : mimeTypes) {
651650
mediaTypes.add(MediaType.asMediaType(mimeType));
652651
}
653652
return mediaTypes;

spring-web/src/main/java/org/springframework/web/bind/support/WebExchangeDataBinder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 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.
@@ -64,7 +64,7 @@ public WebExchangeDataBinder(@Nullable Object target, String objectName) {
6464

6565
/**
6666
* Bind query params, form data, and or multipart form data to the binder target.
67-
* @param exchange the current exchange.
67+
* @param exchange the current exchange
6868
* @return a {@code Mono<Void>} when binding is complete
6969
*/
7070
public Mono<Void> bind(ServerWebExchange exchange) {

spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 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.
@@ -109,12 +109,12 @@ public WebRequestDataBinder(@Nullable Object target, String objectName) {
109109
*/
110110
public void bind(WebRequest request) {
111111
MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap());
112-
if (isMultipartRequest(request) && request instanceof NativeWebRequest) {
112+
if (request instanceof NativeWebRequest) {
113113
MultipartRequest multipartRequest = ((NativeWebRequest) request).getNativeRequest(MultipartRequest.class);
114114
if (multipartRequest != null) {
115115
bindMultipart(multipartRequest.getMultiFileMap(), mpvs);
116116
}
117-
else {
117+
else if (isMultipartRequest(request)) {
118118
HttpServletRequest servletRequest = ((NativeWebRequest) request).getNativeRequest(HttpServletRequest.class);
119119
if (servletRequest != null) {
120120
bindParts(servletRequest, mpvs);
@@ -130,7 +130,7 @@ public void bind(WebRequest request) {
130130
*/
131131
private boolean isMultipartRequest(WebRequest request) {
132132
String contentType = request.getHeader("Content-Type");
133-
return StringUtils.startsWithIgnoreCase(contentType, "multipart");
133+
return StringUtils.startsWithIgnoreCase(contentType, "multipart/");
134134
}
135135

136136
private void bindParts(HttpServletRequest request, MutablePropertyValues mpvs) {

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolver.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 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.
@@ -85,7 +85,6 @@ protected NamedValueInfo createNamedValueInfo(MethodParameter parameter) {
8585
}
8686

8787
@Override
88-
@SuppressWarnings("unchecked")
8988
protected Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange) {
9089
String attributeName = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
9190
return exchange.getAttributeOrDefault(attributeName, Collections.emptyMap()).get(name);
@@ -97,7 +96,6 @@ protected void handleMissingValue(String name, MethodParameter parameter) {
9796
}
9897

9998
@Override
100-
@SuppressWarnings("unchecked")
10199
protected void handleResolvedValue(
102100
@Nullable Object arg, String name, MethodParameter parameter, Model model, ServerWebExchange exchange) {
103101

0 commit comments

Comments
 (0)