Polishing
This commit is contained in:
parent
799589ec1c
commit
1332482c40
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -62,7 +62,7 @@ public class Problem {
|
||||||
/**
|
/**
|
||||||
* Create a new instance of the {@link Problem} class.
|
* Create a new instance of the {@link Problem} class.
|
||||||
* @param message a message detailing the problem
|
* @param message a message detailing the problem
|
||||||
* @param rootCause the underlying expection that caused the error (may be {@code null})
|
* @param rootCause the underlying exception that caused the error (may be {@code null})
|
||||||
* @param parseState the {@link ParseState} at the time of the error
|
* @param parseState the {@link ParseState} at the time of the error
|
||||||
* @param location the location within a bean configuration source that triggered the error
|
* @param location the location within a bean configuration source that triggered the error
|
||||||
*/
|
*/
|
||||||
|
|
@ -107,7 +107,7 @@ public class Problem {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the underlying expection that caused the error (may be {@code null}).
|
* Get the underlying exception that caused the error (may be {@code null}).
|
||||||
*/
|
*/
|
||||||
public Throwable getRootCause() {
|
public Throwable getRootCause() {
|
||||||
return this.rootCause;
|
return this.rootCause;
|
||||||
|
|
|
||||||
|
|
@ -1295,8 +1295,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||||
mbd.setScope(containingBd.getScope());
|
mbd.setScope(containingBd.getScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only cache the merged bean definition if we're already about to create an
|
// Cache the merged bean definition for the time being
|
||||||
// instance of the bean, or at least have already created an instance before.
|
// (it might still get re-merged later on in order to pick up metadata changes)
|
||||||
if (containingBd == null && isCacheBeanMetadata()) {
|
if (containingBd == null && isCacheBeanMetadata()) {
|
||||||
this.mergedBeanDefinitions.put(beanName, mbd);
|
this.mergedBeanDefinitions.put(beanName, mbd);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2014 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -81,7 +81,9 @@ public class ResourceEditor extends PropertyEditorSupport {
|
||||||
* @param ignoreUnresolvablePlaceholders whether to ignore unresolvable placeholders
|
* @param ignoreUnresolvablePlaceholders whether to ignore unresolvable placeholders
|
||||||
* if no corresponding property could be found in the given {@code propertyResolver}
|
* if no corresponding property could be found in the given {@code propertyResolver}
|
||||||
*/
|
*/
|
||||||
public ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) {
|
public ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyResolver,
|
||||||
|
boolean ignoreUnresolvablePlaceholders) {
|
||||||
|
|
||||||
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
|
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
|
||||||
this.resourceLoader = resourceLoader;
|
this.resourceLoader = resourceLoader;
|
||||||
this.propertyResolver = propertyResolver;
|
this.propertyResolver = propertyResolver;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ import static org.springframework.core.annotation.AnnotationUtils.*;
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
* @author Oleg Zhurakousky
|
||||||
*/
|
*/
|
||||||
public class AnnotationUtilsTests {
|
public class AnnotationUtilsTests {
|
||||||
|
|
||||||
|
|
@ -90,7 +91,7 @@ public class AnnotationUtilsTests {
|
||||||
assertNotNull(findAnnotation(m, Order.class));
|
assertNotNull(findAnnotation(m, Order.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Exception {
|
public void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Exception {
|
||||||
Method m = Leaf.class.getMethod("fromInterfaceImplementedByRoot");
|
Method m = Leaf.class.getMethod("fromInterfaceImplementedByRoot");
|
||||||
|
|
@ -102,7 +103,7 @@ public class AnnotationUtilsTests {
|
||||||
assertNotNull(findAnnotation(m, Order.class));
|
assertNotNull(findAnnotation(m, Order.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception {
|
public void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception {
|
||||||
Method m = Leaf.class.getMethod("metaAnnotatedOnLeaf");
|
Method m = Leaf.class.getMethod("metaAnnotatedOnLeaf");
|
||||||
|
|
@ -111,7 +112,7 @@ public class AnnotationUtilsTests {
|
||||||
assertNotNull(findAnnotation(m, Order.class));
|
assertNotNull(findAnnotation(m, Order.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findMethodAnnotationWithMetaMetaAnnotationOnLeaf() throws Exception {
|
public void findMethodAnnotationWithMetaMetaAnnotationOnLeaf() throws Exception {
|
||||||
Method m = Leaf.class.getMethod("metaMetaAnnotatedOnLeaf");
|
Method m = Leaf.class.getMethod("metaMetaAnnotatedOnLeaf");
|
||||||
|
|
@ -128,7 +129,7 @@ public class AnnotationUtilsTests {
|
||||||
assertNotNull(findAnnotation(m, Order.class));
|
assertNotNull(findAnnotation(m, Order.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findMethodAnnotationWithMetaAnnotationOnRoot() throws Exception {
|
public void findMethodAnnotationWithMetaAnnotationOnRoot() throws Exception {
|
||||||
Method m = Leaf.class.getMethod("metaAnnotatedOnRoot");
|
Method m = Leaf.class.getMethod("metaAnnotatedOnRoot");
|
||||||
|
|
@ -258,42 +259,42 @@ public class AnnotationUtilsTests {
|
||||||
assertNull("Should not find @Component on MetaCycleAnnotatedClass", component);
|
assertNull("Should not find @Component on MetaCycleAnnotatedClass", component);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findClassAnnotationOnInheritedAnnotationInterface() {
|
public void findClassAnnotationOnInheritedAnnotationInterface() {
|
||||||
Transactional tx = findAnnotation(InheritedAnnotationInterface.class, Transactional.class);
|
Transactional tx = findAnnotation(InheritedAnnotationInterface.class, Transactional.class);
|
||||||
assertNotNull("Should find @Transactional on InheritedAnnotationInterface", tx);
|
assertNotNull("Should find @Transactional on InheritedAnnotationInterface", tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findClassAnnotationOnSubInheritedAnnotationInterface() {
|
public void findClassAnnotationOnSubInheritedAnnotationInterface() {
|
||||||
Transactional tx = findAnnotation(SubInheritedAnnotationInterface.class, Transactional.class);
|
Transactional tx = findAnnotation(SubInheritedAnnotationInterface.class, Transactional.class);
|
||||||
assertNotNull("Should find @Transactional on SubInheritedAnnotationInterface", tx);
|
assertNotNull("Should find @Transactional on SubInheritedAnnotationInterface", tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findClassAnnotationOnSubSubInheritedAnnotationInterface() {
|
public void findClassAnnotationOnSubSubInheritedAnnotationInterface() {
|
||||||
Transactional tx = findAnnotation(SubSubInheritedAnnotationInterface.class, Transactional.class);
|
Transactional tx = findAnnotation(SubSubInheritedAnnotationInterface.class, Transactional.class);
|
||||||
assertNotNull("Should find @Transactional on SubSubInheritedAnnotationInterface", tx);
|
assertNotNull("Should find @Transactional on SubSubInheritedAnnotationInterface", tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findClassAnnotationOnNonInheritedAnnotationInterface() {
|
public void findClassAnnotationOnNonInheritedAnnotationInterface() {
|
||||||
Order order = findAnnotation(NonInheritedAnnotationInterface.class, Order.class);
|
Order order = findAnnotation(NonInheritedAnnotationInterface.class, Order.class);
|
||||||
assertNotNull("Should find @Order on NonInheritedAnnotationInterface", order);
|
assertNotNull("Should find @Order on NonInheritedAnnotationInterface", order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findClassAnnotationOnSubNonInheritedAnnotationInterface() {
|
public void findClassAnnotationOnSubNonInheritedAnnotationInterface() {
|
||||||
Order order = findAnnotation(SubNonInheritedAnnotationInterface.class, Order.class);
|
Order order = findAnnotation(SubNonInheritedAnnotationInterface.class, Order.class);
|
||||||
assertNotNull("Should find @Order on SubNonInheritedAnnotationInterface", order);
|
assertNotNull("Should find @Order on SubNonInheritedAnnotationInterface", order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 4.2 */
|
// @since 4.2
|
||||||
@Test
|
@Test
|
||||||
public void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() {
|
public void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() {
|
||||||
Order order = findAnnotation(SubSubNonInheritedAnnotationInterface.class, Order.class);
|
Order order = findAnnotation(SubSubNonInheritedAnnotationInterface.class, Order.class);
|
||||||
|
|
@ -1240,6 +1241,11 @@ public class AnnotationUtilsTests {
|
||||||
assertEquals("location: ", "", contextConfig.location());
|
assertEquals("location: ", "", contextConfig.location());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = AnnotationConfigurationException.class)
|
||||||
|
public void synthesizeAnnotationWithAttributeAliasesDifferentValues() throws Exception {
|
||||||
|
getValue(synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class)));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception {
|
public void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception {
|
||||||
Map<String, Object> map = Collections.singletonMap("location", "test.xml");
|
Map<String, Object> map = Collections.singletonMap("location", "test.xml");
|
||||||
|
|
@ -1357,11 +1363,6 @@ public class AnnotationUtilsTests {
|
||||||
assertNotNull(synthesizedWebMapping2);
|
assertNotNull(synthesizedWebMapping2);
|
||||||
|
|
||||||
assertThat(webMappingWithAliases.toString(), is(not(synthesizedWebMapping1.toString())));
|
assertThat(webMappingWithAliases.toString(), is(not(synthesizedWebMapping1.toString())));
|
||||||
|
|
||||||
// The unsynthesized annotation for handleMappedWithSamePathAndValueAttributes()
|
|
||||||
// should produce the same toString() results as synthesized annotations for
|
|
||||||
// handleMappedWithPathAttribute()
|
|
||||||
assertToStringForWebMappingWithPathAndValue(webMappingWithPathAndValue);
|
|
||||||
assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping1);
|
assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping1);
|
||||||
assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping2);
|
assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping2);
|
||||||
}
|
}
|
||||||
|
|
@ -2344,4 +2345,8 @@ public class AnnotationUtilsTests {
|
||||||
String text();
|
String text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ContextConfig(value = "foo", location = "bar")
|
||||||
|
interface ContextConfigMismatch {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,12 +179,11 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||||
* names. Encoding is based on the encoded-word syntax defined in RFC 2047
|
* names. Encoding is based on the encoded-word syntax defined in RFC 2047
|
||||||
* and relies on {@code MimeUtility} from "javax.mail".
|
* and relies on {@code MimeUtility} from "javax.mail".
|
||||||
* <p>If not set file names will be encoded as US-ASCII.
|
* <p>If not set file names will be encoded as US-ASCII.
|
||||||
* @param multipartCharset the charset to use
|
|
||||||
* @since 4.1.1
|
* @since 4.1.1
|
||||||
* @see <a href="http://en.wikipedia.org/wiki/MIME#Encoded-Word">Encoded-Word</a>
|
* @see <a href="http://en.wikipedia.org/wiki/MIME#Encoded-Word">Encoded-Word</a>
|
||||||
*/
|
*/
|
||||||
public void setMultipartCharset(Charset multipartCharset) {
|
public void setMultipartCharset(Charset charset) {
|
||||||
this.multipartCharset = multipartCharset;
|
this.multipartCharset = charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,10 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||||
*/
|
*/
|
||||||
private static final String DEFAULT_STRATEGIES_PATH = "DispatcherServlet.properties";
|
private static final String DEFAULT_STRATEGIES_PATH = "DispatcherServlet.properties";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common prefix that DispatcherServlet's default strategy attributes start with.
|
||||||
|
*/
|
||||||
|
private static final String DEFAULT_STRATEGIES_PREFIX = "org.springframework.web.servlet";
|
||||||
|
|
||||||
/** Additional logger to use when no mapped handler is found for a request. */
|
/** Additional logger to use when no mapped handler is found for a request. */
|
||||||
protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);
|
protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);
|
||||||
|
|
@ -279,7 +283,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||||
defaultStrategies = PropertiesLoaderUtils.loadProperties(resource);
|
defaultStrategies = PropertiesLoaderUtils.loadProperties(resource);
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
throw new IllegalStateException("Could not load 'DispatcherServlet.properties': " + ex.getMessage());
|
throw new IllegalStateException("Could not load '" + DEFAULT_STRATEGIES_PATH + "': " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -874,7 +878,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||||
Enumeration<?> attrNames = request.getAttributeNames();
|
Enumeration<?> attrNames = request.getAttributeNames();
|
||||||
while (attrNames.hasMoreElements()) {
|
while (attrNames.hasMoreElements()) {
|
||||||
String attrName = (String) attrNames.nextElement();
|
String attrName = (String) attrNames.nextElement();
|
||||||
if (this.cleanupAfterInclude || attrName.startsWith("org.springframework.web.servlet")) {
|
if (this.cleanupAfterInclude || attrName.startsWith(DEFAULT_STRATEGIES_PREFIX)) {
|
||||||
attributesSnapshot.put(attrName, request.getAttribute(attrName));
|
attributesSnapshot.put(attrName, request.getAttribute(attrName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1348,7 +1352,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||||
Enumeration<?> attrNames = request.getAttributeNames();
|
Enumeration<?> attrNames = request.getAttributeNames();
|
||||||
while (attrNames.hasMoreElements()) {
|
while (attrNames.hasMoreElements()) {
|
||||||
String attrName = (String) attrNames.nextElement();
|
String attrName = (String) attrNames.nextElement();
|
||||||
if (this.cleanupAfterInclude || attrName.startsWith("org.springframework.web.servlet")) {
|
if (this.cleanupAfterInclude || attrName.startsWith(DEFAULT_STRATEGIES_PREFIX)) {
|
||||||
attrsToCheck.add(attrName);
|
attrsToCheck.add(attrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue