Polishing
This commit is contained in:
@@ -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.
|
||||
@@ -57,9 +57,9 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
||||
boolean candidateFound = false;
|
||||
Set<String> annoTypes = importingClassMetadata.getAnnotationTypes();
|
||||
for (String annoType : annoTypes) {
|
||||
AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
|
||||
Set<String> annTypes = importingClassMetadata.getAnnotationTypes();
|
||||
for (String annType : annTypes) {
|
||||
AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annType);
|
||||
if (candidate == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -125,7 +125,7 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable,
|
||||
* including codes, arguments, and default message.
|
||||
*/
|
||||
protected final String resolvableToString() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
StringBuilder result = new StringBuilder(64);
|
||||
result.append("codes [").append(StringUtils.arrayToDelimitedString(this.codes, ","));
|
||||
result.append("]; arguments [").append(StringUtils.arrayToDelimitedString(this.arguments, ","));
|
||||
result.append("]; default message [").append(this.defaultMessage).append(']');
|
||||
|
||||
@@ -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.
|
||||
@@ -85,7 +85,7 @@ public class ValidatorFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleValidationWithCustomProvider() throws Exception {
|
||||
public void testSimpleValidationWithCustomProvider() {
|
||||
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
|
||||
validator.setProviderClass(HibernateValidator.class);
|
||||
validator.afterPropertiesSet();
|
||||
|
||||
@@ -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.
|
||||
@@ -52,7 +52,7 @@ import static org.junit.Assert.*;
|
||||
public class AnnotationMetadataTests {
|
||||
|
||||
@Test
|
||||
public void standardAnnotationMetadata() throws Exception {
|
||||
public void standardAnnotationMetadata() {
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotatedComponent.class, true);
|
||||
doTestAnnotationInfo(metadata);
|
||||
doTestMethodAnnotationInfo(metadata);
|
||||
@@ -68,7 +68,7 @@ public class AnnotationMetadataTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void standardAnnotationMetadataForSubclass() throws Exception {
|
||||
public void standardAnnotationMetadataForSubclass() {
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotatedComponentSubClass.class, true);
|
||||
doTestSubClassAnnotationInfo(metadata);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class AnnotationMetadataTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void standardAnnotationMetadataForInterface() throws Exception {
|
||||
public void standardAnnotationMetadataForInterface() {
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotationMetadata.class, true);
|
||||
doTestMetadataForInterfaceClass(metadata);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class AnnotationMetadataTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void standardAnnotationMetadataForAnnotation() throws Exception {
|
||||
public void standardAnnotationMetadataForAnnotation() {
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(Component.class, true);
|
||||
doTestMetadataForAnnotationClass(metadata);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class AnnotationMetadataTests {
|
||||
* 'true' as is done in the main test above.
|
||||
*/
|
||||
@Test
|
||||
public void standardAnnotationMetadata_nestedAnnotationsAsMap_false() throws Exception {
|
||||
public void standardAnnotationMetadata_nestedAnnotationsAsMap_false() {
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotatedComponent.class);
|
||||
AnnotationAttributes specialAttrs = (AnnotationAttributes) metadata.getAnnotationAttributes(SpecialAttr.class.getName());
|
||||
Annotation[] nestedAnnoArray = (Annotation[]) specialAttrs.get("nestedAnnoArray");
|
||||
@@ -205,19 +205,13 @@ public class AnnotationMetadataTests {
|
||||
assertThat("length of basePackageClasses[]", basePackageClasses.length, is(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* https://jira.spring.io/browse/SPR-11649
|
||||
*/
|
||||
@Test
|
||||
@Test // SPR-11649
|
||||
public void multipleAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() {
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(NamedAnnotationsClass.class);
|
||||
assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://jira.spring.io/browse/SPR-11649
|
||||
*/
|
||||
@Test
|
||||
@Test // SPR-11649
|
||||
public void multipleAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception {
|
||||
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
|
||||
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedAnnotationsClass.class.getName());
|
||||
@@ -225,19 +219,13 @@ public class AnnotationMetadataTests {
|
||||
assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://jira.spring.io/browse/SPR-11649
|
||||
*/
|
||||
@Test
|
||||
@Test // SPR-11649
|
||||
public void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() {
|
||||
AnnotationMetadata metadata = new StandardAnnotationMetadata(NamedComposedAnnotationClass.class);
|
||||
assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* https://jira.spring.io/browse/SPR-11649
|
||||
*/
|
||||
@Test
|
||||
@Test // SPR-11649
|
||||
public void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception {
|
||||
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
|
||||
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedComposedAnnotationClass.class.getName());
|
||||
|
||||
@@ -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.
|
||||
@@ -32,7 +32,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Helper class for URL path matching. Provides support for URL paths in
|
||||
* RequestDispatcher includes and support for consistent URL decoding.
|
||||
* {@code RequestDispatcher} includes and support for consistent URL decoding.
|
||||
*
|
||||
* <p>Used by {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping},
|
||||
* {@link org.springframework.web.servlet.mvc.multiaction.AbstractUrlMethodNameResolver}
|
||||
@@ -43,6 +43,8 @@ import org.springframework.util.StringUtils;
|
||||
* @author Rob Harrop
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 14.01.2004
|
||||
* @see #getLookupPathForRequest
|
||||
* @see javax.servlet.RequestDispatcher
|
||||
*/
|
||||
public class UrlPathHelper {
|
||||
|
||||
@@ -68,22 +70,29 @@ public class UrlPathHelper {
|
||||
|
||||
|
||||
/**
|
||||
* Set if URL lookup should always use full path within current servlet
|
||||
* context. Else, the path within the current servlet mapping is used
|
||||
* if applicable (i.e. in the case of a ".../*" servlet mapping in web.xml).
|
||||
* Default is "false".
|
||||
* Whether URL lookups should always use the full path within the current
|
||||
* web application context, i.e. within
|
||||
* {@link javax.servlet.ServletContext#getContextPath()}.
|
||||
* <p>If set to {@literal false} the path within the current servlet mapping
|
||||
* is used instead if applicable (i.e. in the case of a prefix based Servlet
|
||||
* mapping such as "/myServlet/*").
|
||||
* <p>By default this is set to "false".
|
||||
*/
|
||||
public void setAlwaysUseFullPath(boolean alwaysUseFullPath) {
|
||||
this.alwaysUseFullPath = alwaysUseFullPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if context path and request URI should be URL-decoded.
|
||||
* Both are returned <i>undecoded</i> by the Servlet API,
|
||||
* in contrast to the servlet path.
|
||||
* <p>Uses either the request encoding or the default encoding according
|
||||
* to the Servlet spec (ISO-8859-1).
|
||||
* <p>Default is "true", as of Spring 2.5.
|
||||
* Whether the context path and request URI should be decoded -- both of
|
||||
* which are returned <i>undecoded</i> by the Servlet API, in contrast to
|
||||
* the servlet path.
|
||||
* <p>Either the request encoding or the default Servlet spec encoding
|
||||
* (ISO-8859-1) is used when set to "true".
|
||||
* <p>By default this is set to {@literal true}.
|
||||
* <p><strong>Note:</strong> Be aware the servlet path will not match when
|
||||
* compared to encoded paths. Therefore use of {@code urlDecode=false} is
|
||||
* not compatible with a prefix-based Servlet mapping and likewise implies
|
||||
* also setting {@code alwaysUseFullPath=true}.
|
||||
* @see #getServletPath
|
||||
* @see #getContextPath
|
||||
* @see #getRequestUri
|
||||
@@ -149,8 +158,8 @@ public class UrlPathHelper {
|
||||
* <p>Detects include request URL if called within a RequestDispatcher include.
|
||||
* @param request current HTTP request
|
||||
* @return the lookup path
|
||||
* @see #getPathWithinApplication
|
||||
* @see #getPathWithinServletMapping
|
||||
* @see #getPathWithinApplication
|
||||
*/
|
||||
public String getLookupPathForRequest(HttpServletRequest request) {
|
||||
// Always use full path within current servlet context?
|
||||
@@ -179,6 +188,7 @@ public class UrlPathHelper {
|
||||
* <p>E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".
|
||||
* @param request current HTTP request
|
||||
* @return the path within the servlet mapping, or ""
|
||||
* @see #getLookupPathForRequest
|
||||
*/
|
||||
public String getPathWithinServletMapping(HttpServletRequest request) {
|
||||
String pathWithinApp = getPathWithinApplication(request);
|
||||
@@ -226,6 +236,7 @@ public class UrlPathHelper {
|
||||
* <p>Detects include request URL if called within a RequestDispatcher include.
|
||||
* @param request current HTTP request
|
||||
* @return the path within the web application
|
||||
* @see #getLookupPathForRequest
|
||||
*/
|
||||
public String getPathWithinApplication(HttpServletRequest request) {
|
||||
String contextPath = getContextPath(request);
|
||||
@@ -279,7 +290,7 @@ public class UrlPathHelper {
|
||||
/**
|
||||
* Sanitize the given path with the following rules:
|
||||
* <ul>
|
||||
* <li>replace all "//" by "/"</li>
|
||||
* <li>replace all "//" by "/"</li>
|
||||
* </ul>
|
||||
*/
|
||||
private String getSanitizedPath(final String path) {
|
||||
|
||||
Reference in New Issue
Block a user