Browse Source

Polishing

pull/22521/head
Juergen Hoeller 7 years ago
parent
commit
df9be494cc
  1. 2
      spring-context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
  2. 6
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
  3. 2
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java
  4. 2
      spring-context/src/main/java/org/springframework/context/event/AbstractApplicationEventMulticaster.java
  5. 2
      spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java
  6. 15
      spring-context/src/main/java/org/springframework/context/support/SimpleThreadScope.java
  7. 4
      spring-core/src/main/java/org/springframework/util/ClassUtils.java
  8. 8
      spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompSession.java
  9. 4
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java
  10. 17
      spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java
  11. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java
  12. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
  13. 10
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceUtils.java
  14. 5
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java
  15. 8
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/HandlerExceptionResolverComposite.java
  16. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java
  17. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategy.java
  18. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java
  19. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SessionAttributeMethodArgumentResolver.java
  20. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ViewMethodReturnValueHandler.java
  21. 20
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ViewNameMethodReturnValueHandler.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -896,7 +896,7 @@ class ConfigurationClassParser { @@ -896,7 +896,7 @@ class ConfigurationClassParser {
return new AssignableTypeFilter(clazz).match((MetadataReader) this.source, metadataReaderFactory);
}
public ConfigurationClass asConfigClass(ConfigurationClass importedBy) throws IOException {
public ConfigurationClass asConfigClass(ConfigurationClass importedBy) {
if (this.source instanceof Class) {
return new ConfigurationClass((Class<?>) this.source, importedBy);
}
@ -964,7 +964,7 @@ class ConfigurationClassParser { @@ -964,7 +964,7 @@ class ConfigurationClassParser {
return result;
}
public Set<SourceClass> getAnnotations() throws IOException {
public Set<SourceClass> getAnnotations() {
Set<SourceClass> result = new LinkedHashSet<>();
for (String className : this.metadata.getAnnotationTypes()) {
try {

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,14 +36,13 @@ import org.springframework.lang.Nullable; @@ -36,14 +36,13 @@ import org.springframework.lang.Nullable;
* or through a {@link org.springframework.beans.factory.config.CustomScopeConfigurer} bean.
*
* <p>{@code SimpleThreadScope} <em>does not clean up any objects</em> associated with it.
* As such, it is typically preferable to use
* {@link org.springframework.web.context.request.RequestScope RequestScope}
* in web environments.
* It is therefore typically preferable to use a request-bound scope implementation such
* as {@code org.springframework.web.context.request.RequestScope} in web environments,
* implementing the full lifecycle for scoped attributes (including reliable destruction).
*
* <p>For an implementation of a thread-based {@code Scope} with support for
* destruction callbacks, refer to the
* <a href="http://www.springbyexample.org/examples/custom-thread-scope-module.html">
* Spring by Example Custom Thread Scope Module</a>.
* <p>For an implementation of a thread-based {@code Scope} with support for destruction
* callbacks, refer to
* <a href="http://www.springbyexample.org/examples/custom-thread-scope-module.html">Spring by Example</a>.
*
* <p>Thanks to Eugene Kuleshov for submitting the original prototype for a thread scope!
*

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -42,7 +42,7 @@ import java.util.Set; @@ -42,7 +42,7 @@ import java.util.Set;
import org.springframework.lang.Nullable;
/**
* Miscellaneous class utility methods.
* Miscellaneous {@code java.lang.Class} utility methods.
* Mainly for internal use within the framework.
*
* @author Juergen Hoeller

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,8 +19,8 @@ package org.springframework.messaging.simp.stomp; @@ -19,8 +19,8 @@ package org.springframework.messaging.simp.stomp;
import org.springframework.lang.Nullable;
/**
* Represents a STOMP session with operations to send messages, create
* subscriptions and receive messages on those subscriptions.
* Represents a STOMP session with operations to send messages,
* create subscriptions and receive messages on those subscriptions.
*
* @author Rossen Stoyanchev
* @since 4.2
@ -63,7 +63,7 @@ public interface StompSession { @@ -63,7 +63,7 @@ public interface StompSession {
* {@link StompHeaders} instead of just a destination. The headers must
* contain a destination and may also have other headers such as
* "content-type" or custom headers for the broker to propagate to
* subscribers, or broker-specific, non-standard headers..
* subscribers, or broker-specific, non-standard headers.
* @param headers the message headers
* @param payload the message payload
* @return a Receiptable for tracking receipts

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1551,7 +1551,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable @@ -1551,7 +1551,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
/**
* Return a {@code HttpHeaders} object that can only be read, not written to.
* Return an {@code HttpHeaders} object that can only be read, not written to.
*/
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
Assert.notNull(headers, "HttpHeaders must not be null");

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -126,7 +126,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa @@ -126,7 +126,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
* @param codecConfigurer the codec configurer to use
*/
public void setCodecConfigurer(ServerCodecConfigurer codecConfigurer) {
Assert.notNull(codecConfigurer, "ServerCodecConfigurer must not be null");
Assert.notNull(codecConfigurer, "ServerCodecConfigurer is required");
this.codecConfigurer = codecConfigurer;
}
@ -159,8 +159,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa @@ -159,8 +159,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
/**
* Configure the {@code ApplicationContext} associated with the web application,
* if it was initialized with one via
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext
* WebHttpHandlerBuilder#applicationContext}.
* {@link org.springframework.web.server.adapter.WebHttpHandlerBuilder#applicationContext(ApplicationContext)}.
* @param applicationContext the context
* @since 5.0.3
*/
@ -204,8 +203,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa @@ -204,8 +203,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
return Mono.empty();
}
if (response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR)) {
logger.error("Failed to handle request [" + request.getMethod() + " "
+ request.getURI() + "]", ex);
logger.error("Failed to handle request [" + request.getMethod() + " " + request.getURI() + "]", ex);
return Mono.empty();
}
// After the response is committed, propagate errors to the server..
@ -216,9 +214,10 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa @@ -216,9 +214,10 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
private boolean isDisconnectedClientError(Throwable ex) {
String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
message = (message != null ? message.toLowerCase() : "");
String className = ex.getClass().getSimpleName();
return (message.contains("broken pipe") || DISCONNECTED_CLIENT_EXCEPTIONS.contains(className));
if (message != null && message.toLowerCase().contains("broken pipe")) {
return true;
}
return DISCONNECTED_CLIENT_EXCEPTIONS.contains(ex.getClass().getSimpleName());
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1120,7 +1120,7 @@ public class DispatcherServlet extends FrameworkServlet { @@ -1120,7 +1120,7 @@ public class DispatcherServlet extends FrameworkServlet {
"this typically results from an additional MultipartFilter in web.xml");
}
else if (hasMultipartException(request)) {
logger.debug("Multipart resolution failed for current request before - " +
logger.debug("Multipart resolution previously failed for current request - " +
"skipping re-resolution for undisturbed error rendering");
}
else {

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -82,8 +82,8 @@ public abstract class MvcNamespaceUtils { @@ -82,8 +82,8 @@ public abstract class MvcNamespaceUtils {
}
parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME);
}
else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)
&& !parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) {
else if (!parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME) &&
!parserContext.getRegistry().containsBeanDefinition(URL_PATH_HELPER_BEAN_NAME)) {
RootBeanDefinition urlPathHelperDef = new RootBeanDefinition(UrlPathHelper.class);
urlPathHelperDef.setSource(source);
urlPathHelperDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
@ -107,8 +107,8 @@ public abstract class MvcNamespaceUtils { @@ -107,8 +107,8 @@ public abstract class MvcNamespaceUtils {
}
parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);
}
else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)
&& !parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
else if (!parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME) &&
!parserContext.getRegistry().containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
RootBeanDefinition pathMatcherDef = new RootBeanDefinition(AntPathMatcher.class);
pathMatcherDef.setSource(source);
pathMatcherDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.util.Comparator; @@ -22,7 +22,6 @@ import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -158,7 +157,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i @@ -158,7 +157,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
* both "/test" and "/team". For details, see the AntPathMatcher class.
* <p>Looks for the most exact pattern, where most exact is defined as
* the longest path pattern.
* @param urlPath URL the bean is mapped to
* @param urlPath the URL the bean is mapped to
* @param request current HTTP request (to expose the path within the mapping to)
* @return the associated handler instance, or {@code null} if not found
* @see #exposePathWithinMapping

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -66,12 +66,12 @@ public class HandlerExceptionResolverComposite implements HandlerExceptionResolv @@ -66,12 +66,12 @@ public class HandlerExceptionResolverComposite implements HandlerExceptionResolv
/**
* Resolve the exception by iterating over the list of configured exception resolvers.
* The first one to return a ModelAndView instance wins. Otherwise {@code null} is returned.
* <p>The first one to return a {@link ModelAndView} wins. Otherwise {@code null} is returned.
*/
@Override
@Nullable
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response,
@Nullable Object handler,Exception ex) {
public ModelAndView resolveException(
HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex) {
if (this.resolvers != null) {
for (HandlerExceptionResolver handlerExceptionResolver : this.resolvers) {

2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/PatternsRequestCondition.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategy.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/SessionAttributeMethodArgumentResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ViewMethodReturnValueHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

20
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ViewNameMethodReturnValueHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,10 +33,10 @@ import org.springframework.web.servlet.RequestToViewNameTranslator; @@ -33,10 +33,10 @@ import org.springframework.web.servlet.RequestToViewNameTranslator;
* as the actual return value is left as-is allowing the configured
* {@link RequestToViewNameTranslator} to select a view name by convention.
*
* <p>A String return value can be interpreted in more than one ways depending
* on the presence of annotations like {@code @ModelAttribute} or
* {@code @ResponseBody}. Therefore this handler should be configured after
* the handlers that support these annotations.
* <p>A String return value can be interpreted in more than one ways depending on
* the presence of annotations like {@code @ModelAttribute} or {@code @ResponseBody}.
* Therefore this handler should be configured after the handlers that support these
* annotations.
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller
@ -49,12 +49,10 @@ public class ViewNameMethodReturnValueHandler implements HandlerMethodReturnValu @@ -49,12 +49,10 @@ public class ViewNameMethodReturnValueHandler implements HandlerMethodReturnValu
/**
* Configure one more simple patterns (as described in
* {@link PatternMatchUtils#simpleMatch}) to use in order to recognize
* custom redirect prefixes in addition to "redirect:".
* <p>Note that simply configuring this property will not make a custom
* redirect prefix work. There must be a custom View that recognizes the
* prefix as well.
* Configure one more simple patterns (as described in {@link PatternMatchUtils#simpleMatch})
* to use in order to recognize custom redirect prefixes in addition to "redirect:".
* <p>Note that simply configuring this property will not make a custom redirect prefix work.
* There must be a custom View that recognizes the prefix as well.
* @since 4.1
*/
public void setRedirectPatterns(@Nullable String... redirectPatterns) {

Loading…
Cancel
Save