Polishing

This commit is contained in:
Juergen Hoeller
2014-07-29 10:10:48 +02:00
parent daaeeaa8e2
commit c0a4631fd1
56 changed files with 845 additions and 794 deletions

View File

@@ -103,7 +103,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
for (String header : headers) {
HeaderExpression expr = new HeaderExpression(header);
if ("Accept".equalsIgnoreCase(expr.name)) {
for( MediaType mediaType : MediaType.parseMediaTypes(expr.value)) {
for (MediaType mediaType : MediaType.parseMediaTypes(expr.value)) {
result.add(new ProduceMediaTypeExpression(mediaType, expr.isNegated));
}
}
@@ -160,7 +160,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
* overrides a type-level "produces" condition.
*/
public ProducesRequestCondition combine(ProducesRequestCondition other) {
return !other.expressions.isEmpty() ? other : this;
return (!other.expressions.isEmpty() ? other : this);
}
/**

View File

@@ -97,7 +97,7 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi
return this;
}
RequestMethod incomingRequestMethod = getRequestMethod(request);
if(incomingRequestMethod != null) {
if (incomingRequestMethod != null) {
for (RequestMethod method : this.methods) {
if (method.equals(incomingRequestMethod)) {
return new RequestMethodsRequestCondition(method);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -28,7 +28,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Source;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -68,34 +67,31 @@ import org.springframework.web.servlet.handler.AbstractHandlerMethodExceptionRes
* @author Rossen Stoyanchev
* @since 3.1
*/
public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExceptionResolver implements
InitializingBean, ApplicationContextAware {
public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExceptionResolver
implements InitializingBean, ApplicationContextAware {
private List<HandlerMethodArgumentResolver> customArgumentResolvers;
private HandlerMethodArgumentResolverComposite argumentResolvers;
private List<HandlerMethodReturnValueHandler> customReturnValueHandlers;
private HandlerMethodReturnValueHandlerComposite returnValueHandlers;
private List<HttpMessageConverter<?>> messageConverters;
private ContentNegotiationManager contentNegotiationManager = new ContentNegotiationManager();
private ApplicationContext applicationContext;
private final Map<Class<?>, ExceptionHandlerMethodResolver> exceptionHandlerCache =
new ConcurrentHashMap<Class<?>, ExceptionHandlerMethodResolver>(64);
private final Map<ControllerAdviceBean, ExceptionHandlerMethodResolver> exceptionHandlerAdviceCache =
new LinkedHashMap<ControllerAdviceBean, ExceptionHandlerMethodResolver>();
private HandlerMethodArgumentResolverComposite argumentResolvers;
private HandlerMethodReturnValueHandlerComposite returnValueHandlers;
private ApplicationContext applicationContext;
/**
* Default constructor.
*/
public ExceptionHandlerExceptionResolver() {
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
stringHttpMessageConverter.setWriteAcceptCharset(false); // See SPR-7316
@@ -106,6 +102,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
this.messageConverters.add(new AllEncompassingFormHttpMessageConverter());
}
/**
* Provide resolvers for custom argument types. Custom resolvers are ordered
* after built-in ones. To override the built-in support for argument
@@ -194,7 +191,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
* Return the configured message body converters.
*/
public List<HttpMessageConverter<?>> getMessageConverters() {
return messageConverters;
return this.messageConverters;
}
/**
@@ -205,7 +202,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
this.contentNegotiationManager = contentNegotiationManager;
}
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@@ -213,6 +210,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
return this.applicationContext;
}
public void afterPropertiesSet() {
if (this.argumentResolvers == null) {
List<HandlerMethodArgumentResolver> resolvers = getDefaultArgumentResolvers();
@@ -291,11 +289,14 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(bean.getBeanType());
if (resolver.hasExceptionMappings()) {
this.exceptionHandlerAdviceCache.put(bean, resolver);
logger.info("Detected @ExceptionHandler methods in " + bean);
if (logger.isDebugEnabled()) {
logger.debug("Detected @ExceptionHandler methods in " + bean);
}
}
}
}
/**
* Find an {@code @ExceptionHandler} method and invoke it to handle the raised exception.
*/
@@ -321,7 +322,9 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
exceptionHandlerMethod.invokeAndHandle(webRequest, mavContainer, exception);
}
catch (Exception invocationEx) {
logger.error("Failed to invoke @ExceptionHandler method: " + exceptionHandlerMethod, invocationEx);
if (logger.isErrorEnabled()) {
logger.error("Failed to invoke @ExceptionHandler method: " + exceptionHandlerMethod, invocationEx);
}
return null;
}
@@ -361,12 +364,14 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
return new ServletInvocableHandlerMethod(handlerMethod.getBean(), method);
}
}
for (Entry<ControllerAdviceBean, ExceptionHandlerMethodResolver> entry : this.exceptionHandlerAdviceCache.entrySet()) {
Method method = entry.getValue().resolveMethod(exception);
if (method != null) {
return new ServletInvocableHandlerMethod(entry.getKey().resolveBean(), method);
}
}
return null;
}

View File

@@ -150,7 +150,8 @@ public class OptionsTag extends AbstractHtmlElementTag {
Object itemsObject = null;
if (items != null) {
itemsObject = (items instanceof String ? evaluate("items", items) : items);
} else {
}
else {
Class<?> selectTagBoundType = selectTag.getBindStatus().getValueType();
if (selectTagBoundType != null && selectTagBoundType.isEnum()) {
itemsObject = selectTagBoundType.getEnumConstants();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -35,19 +35,20 @@ public class PasswordInputTag extends InputTag {
/**
* Is the password value to be rendered?
* @return {@code true} if the password value to be rendered.
* @param showPassword {@code true} if the password value is to be rendered
*/
public void setShowPassword(boolean showPassword) {
this.showPassword = showPassword;
}
/**
* Is the password value to be rendered?
* @return {@code true} if the password value to be rendered
*/
public boolean isShowPassword() {
return this.showPassword;
}
/**
* Is the password value to be rendered?
* @param showPassword {@code true} if the password value is to be rendered.
*/
public void setShowPassword(boolean showPassword) {
this.showPassword = showPassword;
}
/**
* Flags "type" as an illegal dynamic attribute.
@@ -75,8 +76,10 @@ public class PasswordInputTag extends InputTag {
protected void writeValue(TagWriter tagWriter) throws JspException {
if (this.showPassword) {
super.writeValue(tagWriter);
} else {
}
else {
tagWriter.writeAttribute("value", processFieldValue(getName(), "", getType()));
}
}
}