Polishing

This commit is contained in:
Juergen Hoeller
2015-07-30 12:16:59 +02:00
parent 04348901f8
commit e8ef3654c6
28 changed files with 132 additions and 118 deletions

View File

@@ -23,7 +23,6 @@ import org.springframework.util.MultiValueMap;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* A FlashMap provides a way for one request to store attributes intended for
* use in another. This is most commonly needed when redirecting from one URL

View File

@@ -360,6 +360,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
String handlerName = (String) handler;
handler = getApplicationContext().getBean(handlerName);
}
HandlerExecutionChain executionChain = getHandlerExecutionChain(handler, request);
if (CorsUtils.isCorsRequest(request)) {
CorsConfiguration globalConfig = this.corsConfigSource.getCorsConfiguration(request);
@@ -374,17 +375,14 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* Look up a handler for the given request, returning {@code null} if no
* specific one is found. This method is called by {@link #getHandler};
* a {@code null} return value will lead to the default handler, if one is set.
*
* <p>On CORS pre-flight requests this method should return a match not for
* the pre-flight request but for the expected actual request based on the URL
* path, the HTTP methods from the "Access-Control-Request-Method" header, and
* the headers from the "Access-Control-Request-Headers" header thus allowing
* the CORS configuration to be obtained via {@link #getCorsConfigurations},
*
* <p>Note: This method may also return a pre-built {@link HandlerExecutionChain},
* combining a handler object with dynamically determined interceptors.
* Statically specified interceptors will get merged into such an existing chain.
*
* @param request current HTTP request
* @return the corresponding handler instance, or {@code null} if none found
* @throws Exception if there is an internal error
@@ -489,6 +487,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
}
}
private class CorsInterceptor extends HandlerInterceptorAdapter {
private final CorsConfiguration config;

View File

@@ -68,7 +68,7 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
logger.warn("Handling of @ResponseStatus resulted in Exception", resolveEx);
}
}
else if (ex.getCause() != null && ex.getCause() instanceof Exception) {
else if (ex.getCause() instanceof Exception) {
ex = (Exception) ex.getCause();
return doResolveException(request, response, handler, ex);
}

View File

@@ -17,7 +17,6 @@
package org.springframework.web.servlet.resource;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.webjars.MultipleMatchesException;
@@ -52,10 +51,12 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
private final WebJarAssetLocator webJarAssetLocator;
public WebJarsResourceResolver() {
this.webJarAssetLocator = new WebJarAssetLocator();
}
@Override
protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath,
List<? extends Resource> locations, ResourceResolverChain chain) {
@@ -86,7 +87,7 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
protected String findWebJarResourcePath(String path) {
try {
int startOffset = path.startsWith("/") ? 1 : 0;
int startOffset = (path.startsWith("/") ? 1 : 0);
int endOffset = path.indexOf("/", 1);
if (endOffset != -1) {
String webjar = path.substring(startOffset, endOffset);
@@ -94,8 +95,11 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
String webJarPath = webJarAssetLocator.getFullPath(webjar, partialPath);
return webJarPath.substring(WEBJARS_LOCATION_LENGTH);
}
} catch (MultipleMatchesException ex) {
logger.warn("WebJar version conflict for \"" + path + "\"", ex);
}
catch (MultipleMatchesException ex) {
if (logger.isWarnEnabled()) {
logger.warn("WebJar version conflict for \"" + path + "\"", ex);
}
}
catch (IllegalArgumentException ex) {
if (logger.isTraceEnabled()) {

View File

@@ -266,7 +266,8 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException {
try {
return BeanFactoryUtils.beanOfTypeIncludingAncestors(getApplicationContext(), ScriptTemplateConfig.class, true, false);
return BeanFactoryUtils.beanOfTypeIncludingAncestors(
getApplicationContext(), ScriptTemplateConfig.class, true, false);
}
catch (NoSuchBeanDefinitionException ex) {
throw new ApplicationContextException("Expected a single ScriptTemplateConfig bean in the current " +