Skip to content

Commit 9eb7f7e

Browse files
committed
Polishing
1 parent cb54f20 commit 9eb7f7e

22 files changed

+78
-85
lines changed

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

+2-2
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-2019 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.
@@ -377,7 +377,7 @@ private Set<BeanDefinition> addCandidateComponentsFromIndex(CandidateComponentsI
377377
for (TypeFilter filter : this.includeFilters) {
378378
String stereotype = extractStereotype(filter);
379379
if (stereotype == null) {
380-
throw new IllegalArgumentException("Failed to extract stereotype from "+ filter);
380+
throw new IllegalArgumentException("Failed to extract stereotype from " + filter);
381381
}
382382
types.addAll(index.getCandidateTypes(basePackage, stereotype));
383383
}

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

+3-3
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-2019 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.
@@ -946,7 +946,7 @@ public boolean isAssignable(Class<?> clazz) throws IOException {
946946
return new AssignableTypeFilter(clazz).match((MetadataReader) this.source, metadataReaderFactory);
947947
}
948948

949-
public ConfigurationClass asConfigClass(ConfigurationClass importedBy) throws IOException {
949+
public ConfigurationClass asConfigClass(ConfigurationClass importedBy) {
950950
if (this.source instanceof Class) {
951951
return new ConfigurationClass((Class<?>) this.source, importedBy);
952952
}
@@ -1014,7 +1014,7 @@ public Set<SourceClass> getInterfaces() throws IOException {
10141014
return result;
10151015
}
10161016

1017-
public Set<SourceClass> getAnnotations() throws IOException {
1017+
public Set<SourceClass> getAnnotations() {
10181018
Set<SourceClass> result = new LinkedHashSet<>();
10191019
for (String className : this.metadata.getAnnotationTypes()) {
10201020
try {

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

+2-2
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-2019 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.
@@ -435,7 +435,7 @@ public PropertyValues postProcessProperties(@Nullable PropertyValues pvs, Object
435435
}
436436

437437
@Override
438-
public Object postProcessBeforeInitialization(Object bean, String beanName) {
438+
public Object postProcessBeforeInitialization(Object bean, String beanName) {
439439
if (bean instanceof ImportAware) {
440440
ImportRegistry ir = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class);
441441
AnnotationMetadata importingClass = ir.getImportingClassFor(bean.getClass().getSuperclass().getName());

spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java

+2-2
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-2019 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.
@@ -269,7 +269,7 @@ private Collection<ApplicationListener<?>> retrieveApplicationListeners(
269269
* type before trying to instantiate it.
270270
* <p>If this method returns {@code true} for a given listener as a first pass,
271271
* the listener instance will get retrieved and fully evaluated through a
272-
* {@link #supportsEvent(ApplicationListener,ResolvableType, Class)} call afterwards.
272+
* {@link #supportsEvent(ApplicationListener, ResolvableType, Class)} call afterwards.
273273
* @param listenerType the listener's type as determined by the BeanFactory
274274
* @param eventType the event type to check
275275
* @return whether the given listener should be included in the candidates

spring-context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> an
12511251
@Override
12521252
@Nullable
12531253
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
1254-
throws NoSuchBeanDefinitionException{
1254+
throws NoSuchBeanDefinitionException {
12551255

12561256
assertBeanFactoryActive();
12571257
return getBeanFactory().findAnnotationOnBean(beanName, annotationType);

spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java

+2-2
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-2019 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.
@@ -377,7 +377,7 @@ protected String getStringOrNull(ResourceBundle bundle, String key) {
377377
try {
378378
return bundle.getString(key);
379379
}
380-
catch (MissingResourceException ex){
380+
catch (MissingResourceException ex) {
381381
// Assume key not found for some other reason
382382
// -> do NOT throw the exception to allow for checking parent message source.
383383
}

spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java

+7-8
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-2019 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.
@@ -36,14 +36,13 @@
3636
* or through a {@link org.springframework.beans.factory.config.CustomScopeConfigurer} bean.
3737
*
3838
* <p>{@code SimpleThreadScope} <em>does not clean up any objects</em> associated with it.
39-
* As such, it is typically preferable to use
40-
* {@link org.springframework.web.context.request.RequestScope RequestScope}
41-
* in web environments.
39+
* It is therefore typically preferable to use a request-bound scope implementation such
40+
* as {@code org.springframework.web.context.request.RequestScope} in web environments,
41+
* implementing the full lifecycle for scoped attributes (including reliable destruction).
4242
*
43-
* <p>For an implementation of a thread-based {@code Scope} with support for
44-
* destruction callbacks, refer to the
45-
* <a href="http://www.springbyexample.org/examples/custom-thread-scope-module.html">
46-
* Spring by Example Custom Thread Scope Module</a>.
43+
* <p>For an implementation of a thread-based {@code Scope} with support for destruction
44+
* callbacks, refer to
45+
* <a href="http://www.springbyexample.org/examples/custom-thread-scope-module.html">Spring by Example</a>.
4746
*
4847
* <p>Thanks to Eugene Kuleshov for submitting the original prototype for a thread scope!
4948
*

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

+2-2
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-2019 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.
@@ -42,7 +42,7 @@
4242
import org.springframework.lang.Nullable;
4343

4444
/**
45-
* Miscellaneous class utility methods.
45+
* Miscellaneous {@code java.lang.Class} utility methods.
4646
* Mainly for internal use within the framework.
4747
*
4848
* @author Juergen Hoeller

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

+4-4
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-2019 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,8 +19,8 @@
1919
import org.springframework.lang.Nullable;
2020

2121
/**
22-
* Represents a STOMP session with operations to send messages, create
23-
* subscriptions and receive messages on those subscriptions.
22+
* Represents a STOMP session with operations to send messages,
23+
* create subscriptions and receive messages on those subscriptions.
2424
*
2525
* @author Rossen Stoyanchev
2626
* @since 4.2
@@ -63,7 +63,7 @@ public interface StompSession {
6363
* {@link StompHeaders} instead of just a destination. The headers must
6464
* contain a destination and may also have other headers such as
6565
* "content-type" or custom headers for the broker to propagate to
66-
* subscribers, or broker-specific, non-standard headers..
66+
* subscribers, or broker-specific, non-standard headers.
6767
* @param headers the message headers
6868
* @param payload the message payload
6969
* @return a Receiptable for tracking receipts

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ public String toString() {
16811681

16821682

16831683
/**
1684-
* Return a {@code HttpHeaders} object that can only be read, not written to.
1684+
* Return an {@code HttpHeaders} object that can only be read, not written to.
16851685
*/
16861686
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
16871687
Assert.notNull(headers, "HttpHeaders must not be null");
@@ -1694,7 +1694,7 @@ public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
16941694
}
16951695

16961696
/**
1697-
* Return a {@code HttpHeaders} object that can be read and written to.
1697+
* Return an {@code HttpHeaders} object that can be read and written to.
16981698
* @since 5.1.1
16991699
*/
17001700
public static HttpHeaders writableHttpHeaders(HttpHeaders headers) {

spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java

+8-11
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-2019 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.
@@ -197,8 +197,7 @@ public ForwardedHeaderTransformer getForwardedHeaderTransformer() {
197197
/**
198198
* Configure the {@code ApplicationContext} associated with the web application,
199199
* if it was initialized with one via
200-
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext
201-
* WebHttpHandlerBuilder#applicationContext}.
200+
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext(ApplicationContext)}.
202201
* @param applicationContext the context
203202
* @since 5.0.3
204203
*/
@@ -232,11 +231,9 @@ public void afterPropertiesSet() {
232231

233232
@Override
234233
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
235-
236234
if (this.forwardedHeaderTransformer != null) {
237235
request = this.forwardedHeaderTransformer.apply(request);
238236
}
239-
240237
ServerWebExchange exchange = createExchange(request, response);
241238

242239
LogFormatUtils.traceDebug(logger, traceOn ->
@@ -274,7 +271,6 @@ private String formatHeaders(HttpHeaders responseHeaders) {
274271
}
275272

276273
private Mono<Void> handleUnresolvedError(ServerWebExchange exchange, Throwable ex) {
277-
278274
ServerHttpRequest request = exchange.getRequest();
279275
ServerHttpResponse response = exchange.getResponse();
280276
String logPrefix = exchange.getLogPrefix();
@@ -294,18 +290,19 @@ else if (response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR)) {
294290
return Mono.empty();
295291
}
296292
else {
297-
// After the response is committed, propagate errors to the server..
293+
// After the response is committed, propagate errors to the server...
298294
logger.error(logPrefix + "Error [" + ex + "] for " + formatRequest(request) +
299295
", but ServerHttpResponse already committed (" + response.getStatusCode() + ")");
300296
return Mono.error(ex);
301297
}
302298
}
303299

304-
private boolean isDisconnectedClientError(Throwable ex) {
300+
private boolean isDisconnectedClientError(Throwable ex) {
305301
String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
306-
message = (message != null ? message.toLowerCase() : "");
307-
String className = ex.getClass().getSimpleName();
308-
return (message.contains("broken pipe") || DISCONNECTED_CLIENT_EXCEPTIONS.contains(className));
302+
if (message != null && message.toLowerCase().contains("broken pipe")) {
303+
return true;
304+
}
305+
return DISCONNECTED_CLIENT_EXCEPTIONS.contains(ex.getClass().getSimpleName());
309306
}
310307

311308
}

spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

+5-5
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-2019 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.
@@ -960,7 +960,7 @@ private void logRequest(HttpServletRequest request) {
960960
.collect(Collectors.joining(", "));
961961
}
962962
else {
963-
params = (request.getParameterMap().isEmpty() ? "" : "masked");
963+
params = (request.getParameterMap().isEmpty() ? "" : "masked");
964964
}
965965

966966
String query = StringUtils.isEmpty(request.getQueryString()) ? "" : "?" + request.getQueryString();
@@ -1166,7 +1166,7 @@ protected HttpServletRequest checkMultipart(HttpServletRequest request) throws M
11661166
logger.trace("Request already resolved to MultipartHttpServletRequest, e.g. by MultipartFilter");
11671167
}
11681168
}
1169-
else if (hasMultipartException(request) ) {
1169+
else if (hasMultipartException(request)) {
11701170
logger.debug("Multipart resolution previously failed for current request - " +
11711171
"skipping re-resolution for undisturbed error rendering");
11721172
}
@@ -1432,7 +1432,7 @@ private void triggerAfterCompletion(HttpServletRequest request, HttpServletRespo
14321432
* @param attributesSnapshot the snapshot of the request attributes before the include
14331433
*/
14341434
@SuppressWarnings("unchecked")
1435-
private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?,?> attributesSnapshot) {
1435+
private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?, ?> attributesSnapshot) {
14361436
// Need to copy into separate Collection here, to avoid side effects
14371437
// on the Enumeration when removing attributes.
14381438
Set<String> attrsToCheck = new HashSet<>();
@@ -1451,7 +1451,7 @@ private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?,?>
14511451
// or removing the attribute, respectively, if appropriate.
14521452
for (String attrName : attrsToCheck) {
14531453
Object attrValue = attributesSnapshot.get(attrName);
1454-
if (attrValue == null){
1454+
if (attrValue == null) {
14551455
request.removeAttribute(attrName);
14561456
}
14571457
else if (attrValue != request.getAttribute(attrName)) {

spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java

+4-4
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-2019 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.
@@ -213,7 +213,7 @@ public BeanDefinition parse(Element element, ParserContext context) {
213213
}
214214

215215
configurePathMatchingProperties(handlerMappingDef, element, context);
216-
readerContext.getRegistry().registerBeanDefinition(HANDLER_MAPPING_BEAN_NAME , handlerMappingDef);
216+
readerContext.getRegistry().registerBeanDefinition(HANDLER_MAPPING_BEAN_NAME, handlerMappingDef);
217217

218218
RuntimeBeanReference corsRef = MvcNamespaceUtils.registerCorsConfigurations(null, context, source);
219219
handlerMappingDef.getPropertyValues().add("corsConfigurations", corsRef);
@@ -265,7 +265,7 @@ public BeanDefinition parse(Element element, ParserContext context) {
265265

266266
handlerAdapterDef.getPropertyValues().add("callableInterceptors", callableInterceptors);
267267
handlerAdapterDef.getPropertyValues().add("deferredResultInterceptors", deferredResultInterceptors);
268-
readerContext.getRegistry().registerBeanDefinition(HANDLER_ADAPTER_BEAN_NAME , handlerAdapterDef);
268+
readerContext.getRegistry().registerBeanDefinition(HANDLER_ADAPTER_BEAN_NAME, handlerAdapterDef);
269269

270270
RootBeanDefinition uriContributorDef =
271271
new RootBeanDefinition(CompositeUriComponentsContributorFactoryBean.class);
@@ -391,7 +391,7 @@ private RuntimeBeanReference getContentNegotiationManager(
391391
factoryBeanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
392392
factoryBeanDef.getPropertyValues().add("mediaTypes", getDefaultMediaTypes());
393393
String name = CONTENT_NEGOTIATION_MANAGER_BEAN_NAME;
394-
context.getReaderContext().getRegistry().registerBeanDefinition(name , factoryBeanDef);
394+
context.getReaderContext().getRegistry().registerBeanDefinition(name, factoryBeanDef);
395395
context.registerComponent(new BeanComponentDefinition(factoryBeanDef, name));
396396
beanRef = new RuntimeBeanReference(name);
397397
}

spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java

+7-7
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-2019 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.
@@ -82,8 +82,8 @@ public static RuntimeBeanReference registerUrlPathHelper(
8282
}
8383
parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME);
8484
}
85-
else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)
86-
&& !parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) {
85+
else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME) &&
86+
!parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) {
8787
RootBeanDefinition urlPathHelperDef = new RootBeanDefinition(UrlPathHelper.class);
8888
urlPathHelperDef.setSource(source);
8989
urlPathHelperDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
@@ -107,8 +107,8 @@ public static RuntimeBeanReference registerPathMatcher(@Nullable RuntimeBeanRefe
107107
}
108108
parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);
109109
}
110-
else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)
111-
&& !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
110+
else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME) &&
111+
!parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
112112
RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class);
113113
pathMatcherDef.setSource(source);
114114
pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
@@ -123,7 +123,7 @@ else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)
123123
* name unless already registered.
124124
*/
125125
private static void registerBeanNameUrlHandlerMapping(ParserContext context, @Nullable Object source) {
126-
if (!context.getRegistry().containsBeanDefinition(BEAN_NAME_URL_HANDLER_MAPPING_BEAN_NAME)){
126+
if (!context.getRegistry().containsBeanDefinition(BEAN_NAME_URL_HANDLER_MAPPING_BEAN_NAME)) {
127127
RootBeanDefinition mappingDef = new RootBeanDefinition(BeanNameUrlHandlerMapping.class);
128128
mappingDef.setSource(source);
129129
mappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
@@ -195,7 +195,7 @@ else if (corsConfigurations != null) {
195195
* unless already registered.
196196
*/
197197
private static void registerHandlerMappingIntrospector(ParserContext parserContext, @Nullable Object source) {
198-
if (!parserContext.getRegistry().containsBeanDefinition(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME)){
198+
if (!parserContext.getRegistry().containsBeanDefinition(HANDLER_MAPPING_INTROSPECTOR_BEAN_NAME)) {
199199
RootBeanDefinition beanDef = new RootBeanDefinition(HandlerMappingIntrospector.class);
200200
beanDef.setSource(source);
201201
beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java

+2-2
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-2019 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.
@@ -179,7 +179,7 @@ protected Object lookupHandler(String urlPath, HttpServletRequest request) throw
179179
}
180180
else if (useTrailingSlashMatch()) {
181181
if (!registeredPattern.endsWith("/") && getPathMatcher().match(registeredPattern + "/", urlPath)) {
182-
matchingPatterns.add(registeredPattern +"/");
182+
matchingPatterns.add(registeredPattern + "/");
183183
}
184184
}
185185
}

0 commit comments

Comments
 (0)