Skip to content

Commit df9be49

Browse files
committed
Polishing
1 parent 60be516 commit df9be49

22 files changed

+80
-85
lines changed

spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.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-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

Lines changed: 3 additions & 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-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.
@@ -896,7 +896,7 @@ public boolean isAssignable(Class<?> clazz) throws IOException {
896896
return new AssignableTypeFilter(clazz).match((MetadataReader) this.source, metadataReaderFactory);
897897
}
898898

899-
public ConfigurationClass asConfigClass(ConfigurationClass importedBy) throws IOException {
899+
public ConfigurationClass asConfigClass(ConfigurationClass importedBy) {
900900
if (this.source instanceof Class) {
901901
return new ConfigurationClass((Class<?>) this.source, importedBy);
902902
}
@@ -964,7 +964,7 @@ public Set<SourceClass> getInterfaces() throws IOException {
964964
return result;
965965
}
966966

967-
public Set<SourceClass> getAnnotations() throws IOException {
967+
public Set<SourceClass> getAnnotations() {
968968
Set<SourceClass> result = new LinkedHashSet<>();
969969
for (String className : this.metadata.getAnnotationTypes()) {
970970
try {

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

Lines changed: 2 additions & 2 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-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.
@@ -438,7 +438,7 @@ public PropertyValues postProcessPropertyValues(
438438
}
439439

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

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

Lines changed: 2 additions & 2 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-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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> an
12431243
@Override
12441244
@Nullable
12451245
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
1246-
throws NoSuchBeanDefinitionException{
1246+
throws NoSuchBeanDefinitionException {
12471247

12481248
assertBeanFactoryActive();
12491249
return getBeanFactory().findAnnotationOnBean(beanName, annotationType);

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

Lines changed: 2 additions & 2 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-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.
@@ -329,7 +329,7 @@ protected String getStringOrNull(ResourceBundle bundle, String key) {
329329
try {
330330
return bundle.getString(key);
331331
}
332-
catch (MissingResourceException ex){
332+
catch (MissingResourceException ex) {
333333
// Assume key not found for some other reason
334334
// -> do NOT throw the exception to allow for checking parent message source.
335335
}

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

Lines changed: 7 additions & 8 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-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

Lines changed: 2 additions & 2 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-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

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-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

Lines changed: 2 additions & 2 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-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.
@@ -1551,7 +1551,7 @@ public String toString() {
15511551

15521552

15531553
/**
1554-
* Return a {@code HttpHeaders} object that can only be read, not written to.
1554+
* Return an {@code HttpHeaders} object that can only be read, not written to.
15551555
*/
15561556
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
15571557
Assert.notNull(headers, "HttpHeaders must not be null");

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

Lines changed: 9 additions & 10 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-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.
@@ -126,7 +126,7 @@ public WebSessionManager getSessionManager() {
126126
* @param codecConfigurer the codec configurer to use
127127
*/
128128
public void setCodecConfigurer(ServerCodecConfigurer codecConfigurer) {
129-
Assert.notNull(codecConfigurer, "ServerCodecConfigurer must not be null");
129+
Assert.notNull(codecConfigurer, "ServerCodecConfigurer is required");
130130
this.codecConfigurer = codecConfigurer;
131131
}
132132

@@ -159,8 +159,7 @@ public LocaleContextResolver getLocaleContextResolver() {
159159
/**
160160
* Configure the {@code ApplicationContext} associated with the web application,
161161
* if it was initialized with one via
162-
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext
163-
* WebHttpHandlerBuilder#applicationContext}.
162+
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext(ApplicationContext)}.
164163
* @param applicationContext the context
165164
* @since 5.0.3
166165
*/
@@ -204,8 +203,7 @@ else if (disconnectedClientLogger.isDebugEnabled()) {
204203
return Mono.empty();
205204
}
206205
if (response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR)) {
207-
logger.error("Failed to handle request [" + request.getMethod() + " "
208-
+ request.getURI() + "]", ex);
206+
logger.error("Failed to handle request [" + request.getMethod() + " " + request.getURI() + "]", ex);
209207
return Mono.empty();
210208
}
211209
// After the response is committed, propagate errors to the server..
@@ -214,11 +212,12 @@ else if (disconnectedClientLogger.isDebugEnabled()) {
214212
return Mono.error(ex);
215213
}
216214

217-
private boolean isDisconnectedClientError(Throwable ex) {
215+
private boolean isDisconnectedClientError(Throwable ex) {
218216
String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
219-
message = (message != null ? message.toLowerCase() : "");
220-
String className = ex.getClass().getSimpleName();
221-
return (message.contains("broken pipe") || DISCONNECTED_CLIENT_EXCEPTIONS.contains(className));
217+
if (message != null && message.toLowerCase().contains("broken pipe")) {
218+
return true;
219+
}
220+
return DISCONNECTED_CLIENT_EXCEPTIONS.contains(ex.getClass().getSimpleName());
222221
}
223222

224223
}

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

Lines changed: 5 additions & 5 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-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.
@@ -1119,8 +1119,8 @@ protected HttpServletRequest checkMultipart(HttpServletRequest request) throws M
11191119
logger.debug("Request is already a MultipartHttpServletRequest - if not in a forward, " +
11201120
"this typically results from an additional MultipartFilter in web.xml");
11211121
}
1122-
else if (hasMultipartException(request) ) {
1123-
logger.debug("Multipart resolution failed for current request before - " +
1122+
else if (hasMultipartException(request)) {
1123+
logger.debug("Multipart resolution previously failed for current request - " +
11241124
"skipping re-resolution for undisturbed error rendering");
11251125
}
11261126
else {
@@ -1388,7 +1388,7 @@ private void triggerAfterCompletion(HttpServletRequest request, HttpServletRespo
13881388
* @param attributesSnapshot the snapshot of the request attributes before the include
13891389
*/
13901390
@SuppressWarnings("unchecked")
1391-
private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?,?> attributesSnapshot) {
1391+
private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?, ?> attributesSnapshot) {
13921392
// Need to copy into separate Collection here, to avoid side effects
13931393
// on the Enumeration when removing attributes.
13941394
Set<String> attrsToCheck = new HashSet<>();
@@ -1407,7 +1407,7 @@ private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?,?>
14071407
// or removing the attribute, respectively, if appropriate.
14081408
for (String attrName : attrsToCheck) {
14091409
Object attrValue = attributesSnapshot.get(attrName);
1410-
if (attrValue == null){
1410+
if (attrValue == null) {
14111411
request.removeAttribute(attrName);
14121412
}
14131413
else if (attrValue != request.getAttribute(attrName)) {

spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.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-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.
@@ -218,7 +218,7 @@ public BeanDefinition parse(Element element, ParserContext context) {
218218
}
219219

220220
configurePathMatchingProperties(handlerMappingDef, element, context);
221-
readerContext.getRegistry().registerBeanDefinition(HANDLER_MAPPING_BEAN_NAME , handlerMappingDef);
221+
readerContext.getRegistry().registerBeanDefinition(HANDLER_MAPPING_BEAN_NAME, handlerMappingDef);
222222

223223
RuntimeBeanReference corsRef = MvcNamespaceUtils.registerCorsConfigurations(null, context, source);
224224
handlerMappingDef.getPropertyValues().add("corsConfigurations", corsRef);
@@ -270,7 +270,7 @@ public BeanDefinition parse(Element element, ParserContext context) {
270270

271271
handlerAdapterDef.getPropertyValues().add("callableInterceptors", callableInterceptors);
272272
handlerAdapterDef.getPropertyValues().add("deferredResultInterceptors", deferredResultInterceptors);
273-
readerContext.getRegistry().registerBeanDefinition(HANDLER_ADAPTER_BEAN_NAME , handlerAdapterDef);
273+
readerContext.getRegistry().registerBeanDefinition(HANDLER_ADAPTER_BEAN_NAME, handlerAdapterDef);
274274

275275
RootBeanDefinition uriContributorDef =
276276
new RootBeanDefinition(CompositeUriComponentsContributorFactoryBean.class);
@@ -396,7 +396,7 @@ private RuntimeBeanReference getContentNegotiationManager(
396396
factoryBeanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
397397
factoryBeanDef.getPropertyValues().add("mediaTypes", getDefaultMediaTypes());
398398
String name = CONTENT_NEGOTIATION_MANAGER_BEAN_NAME;
399-
context.getReaderContext().getRegistry().registerBeanDefinition(name , factoryBeanDef);
399+
context.getReaderContext().getRegistry().registerBeanDefinition(name, factoryBeanDef);
400400
context.registerComponent(new BeanComponentDefinition(factoryBeanDef, name));
401401
beanRef = new RuntimeBeanReference(name);
402402
}

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

Lines changed: 7 additions & 7 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-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

Lines changed: 3 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-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.
@@ -22,7 +22,6 @@
2222
import java.util.LinkedHashMap;
2323
import java.util.List;
2424
import java.util.Map;
25-
2625
import javax.servlet.http.HttpServletRequest;
2726
import javax.servlet.http.HttpServletResponse;
2827

@@ -158,7 +157,7 @@ else if (handler == null && logger.isTraceEnabled()) {
158157
* both "/test" and "/team". For details, see the AntPathMatcher class.
159158
* <p>Looks for the most exact pattern, where most exact is defined as
160159
* the longest path pattern.
161-
* @param urlPath URL the bean is mapped to
160+
* @param urlPath the URL the bean is mapped to
162161
* @param request current HTTP request (to expose the path within the mapping to)
163162
* @return the associated handler instance, or {@code null} if not found
164163
* @see #exposePathWithinMapping
@@ -186,7 +185,7 @@ protected Object lookupHandler(String urlPath, HttpServletRequest request) throw
186185
}
187186
else if (useTrailingSlashMatch()) {
188187
if (!registeredPattern.endsWith("/") && getPathMatcher().match(registeredPattern + "/", urlPath)) {
189-
matchingPatterns.add(registeredPattern +"/");
188+
matchingPatterns.add(registeredPattern + "/");
190189
}
191190
}
192191
}

0 commit comments

Comments
 (0)