diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java b/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java index 7ef91660ffd671fd0f8b709c9008b5184c13f1c5..770070b35457c9d5d66d2b87292ab35efccbf736 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java @@ -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 annoTypes = importingClassMetadata.getAnnotationTypes(); - for (String annoType : annoTypes) { - AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType); + Set annTypes = importingClassMetadata.getAnnotationTypes(); + for (String annType : annTypes) { + AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annType); if (candidate == null) { continue; } diff --git a/spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java b/spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java index a7058f5f33b272088442147d3f3f7fda24768a85..a32aaafbcb8732556f5e972c115ee5d6033729ea 100644 --- a/spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java +++ b/spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java @@ -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(']'); diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java index 1b26a5db6fe9ebefd67afc9010b9841f8b2f9662..876f069ed769eee19af949c58e2bb994f8e9e6f9 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java @@ -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(); diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index 3a02a208e8190a376cd76c7bb585041b1c06be43..df79044e5029dd8da1d490bbca9fb11b90f7b175 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -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()); diff --git a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java index c343564bc21372a422d0aeab98c9ac4fb8f3fdc3..789ed409c240ed673e852258b394757dec776265 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java +++ b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java @@ -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. * *

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()}. + *

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/*"). + *

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 undecoded by the Servlet API, - * in contrast to the servlet path. - *

Uses either the request encoding or the default encoding according - * to the Servlet spec (ISO-8859-1). - *

Default is "true", as of Spring 2.5. + * Whether the context path and request URI should be decoded -- both of + * which are returned undecoded by the Servlet API, in contrast to + * the servlet path. + *

Either the request encoding or the default Servlet spec encoding + * (ISO-8859-1) is used when set to "true". + *

By default this is set to {@literal true}. + *

Note: 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 { *

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 { *

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 { *

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: *

*/ private String getSanitizedPath(final String path) {