Skip to content

Commit 54dd833

Browse files
committed
Polishing
1 parent 5d1787b commit 54dd833

File tree

5 files changed

+43
-44
lines changed

5 files changed

+43
-44
lines changed

spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,9 +57,9 @@ public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
5757
@Override
5858
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
5959
boolean candidateFound = false;
60-
Set<String> annoTypes = importingClassMetadata.getAnnotationTypes();
61-
for (String annoType : annoTypes) {
62-
AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
60+
Set<String> annTypes = importingClassMetadata.getAnnotationTypes();
61+
for (String annType : annTypes) {
62+
AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annType);
6363
if (candidate == null) {
6464
continue;
6565
}

spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -125,7 +125,7 @@ public String getDefaultMessage() {
125125
* including codes, arguments, and default message.
126126
*/
127127
protected final String resolvableToString() {
128-
StringBuilder result = new StringBuilder();
128+
StringBuilder result = new StringBuilder(64);
129129
result.append("codes [").append(StringUtils.arrayToDelimitedString(this.codes, ","));
130130
result.append("]; arguments [").append(StringUtils.arrayToDelimitedString(this.arguments, ","));
131131
result.append("]; default message [").append(this.defaultMessage).append(']');

spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -85,7 +85,7 @@ public void testSimpleValidation() {
8585
}
8686

8787
@Test
88-
public void testSimpleValidationWithCustomProvider() throws Exception {
88+
public void testSimpleValidationWithCustomProvider() {
8989
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
9090
validator.setProviderClass(HibernateValidator.class);
9191
validator.afterPropertiesSet();

spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@
5252
public class AnnotationMetadataTests {
5353

5454
@Test
55-
public void standardAnnotationMetadata() throws Exception {
55+
public void standardAnnotationMetadata() {
5656
AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotatedComponent.class, true);
5757
doTestAnnotationInfo(metadata);
5858
doTestMethodAnnotationInfo(metadata);
@@ -68,7 +68,7 @@ public void asmAnnotationMetadata() throws Exception {
6868
}
6969

7070
@Test
71-
public void standardAnnotationMetadataForSubclass() throws Exception {
71+
public void standardAnnotationMetadataForSubclass() {
7272
AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotatedComponentSubClass.class, true);
7373
doTestSubClassAnnotationInfo(metadata);
7474
}
@@ -104,7 +104,7 @@ private void doTestSubClassAnnotationInfo(AnnotationMetadata metadata) {
104104
}
105105

106106
@Test
107-
public void standardAnnotationMetadataForInterface() throws Exception {
107+
public void standardAnnotationMetadataForInterface() {
108108
AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotationMetadata.class, true);
109109
doTestMetadataForInterfaceClass(metadata);
110110
}
@@ -132,7 +132,7 @@ private void doTestMetadataForInterfaceClass(AnnotationMetadata metadata) {
132132
}
133133

134134
@Test
135-
public void standardAnnotationMetadataForAnnotation() throws Exception {
135+
public void standardAnnotationMetadataForAnnotation() {
136136
AnnotationMetadata metadata = new StandardAnnotationMetadata(Component.class, true);
137137
doTestMetadataForAnnotationClass(metadata);
138138
}
@@ -172,7 +172,7 @@ private void doTestMetadataForAnnotationClass(AnnotationMetadata metadata) {
172172
* 'true' as is done in the main test above.
173173
*/
174174
@Test
175-
public void standardAnnotationMetadata_nestedAnnotationsAsMap_false() throws Exception {
175+
public void standardAnnotationMetadata_nestedAnnotationsAsMap_false() {
176176
AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotatedComponent.class);
177177
AnnotationAttributes specialAttrs = (AnnotationAttributes) metadata.getAnnotationAttributes(SpecialAttr.class.getName());
178178
Annotation[] nestedAnnoArray = (Annotation[]) specialAttrs.get("nestedAnnoArray");
@@ -205,39 +205,27 @@ private void assertMetaAnnotationOverrides(AnnotationMetadata metadata) {
205205
assertThat("length of basePackageClasses[]", basePackageClasses.length, is(0));
206206
}
207207

208-
/**
209-
* https://jira.spring.io/browse/SPR-11649
210-
*/
211-
@Test
208+
@Test // SPR-11649
212209
public void multipleAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() {
213210
AnnotationMetadata metadata = new StandardAnnotationMetadata(NamedAnnotationsClass.class);
214211
assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
215212
}
216213

217-
/**
218-
* https://jira.spring.io/browse/SPR-11649
219-
*/
220-
@Test
214+
@Test // SPR-11649
221215
public void multipleAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception {
222216
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
223217
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedAnnotationsClass.class.getName());
224218
AnnotationMetadata metadata = metadataReader.getAnnotationMetadata();
225219
assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
226220
}
227221

228-
/**
229-
* https://jira.spring.io/browse/SPR-11649
230-
*/
231-
@Test
222+
@Test // SPR-11649
232223
public void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() {
233224
AnnotationMetadata metadata = new StandardAnnotationMetadata(NamedComposedAnnotationClass.class);
234225
assertMultipleAnnotationsWithIdenticalAttributeNames(metadata);
235226
}
236227

237-
/**
238-
* https://jira.spring.io/browse/SPR-11649
239-
*/
240-
@Test
228+
@Test // SPR-11649
241229
public void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception {
242230
MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory();
243231
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedComposedAnnotationClass.class.getName());

spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@
3232

3333
/**
3434
* Helper class for URL path matching. Provides support for URL paths in
35-
* RequestDispatcher includes and support for consistent URL decoding.
35+
* {@code RequestDispatcher} includes and support for consistent URL decoding.
3636
*
3737
* <p>Used by {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping},
3838
* {@link org.springframework.web.servlet.mvc.multiaction.AbstractUrlMethodNameResolver}
@@ -43,6 +43,8 @@
4343
* @author Rob Harrop
4444
* @author Rossen Stoyanchev
4545
* @since 14.01.2004
46+
* @see #getLookupPathForRequest
47+
* @see javax.servlet.RequestDispatcher
4648
*/
4749
public class UrlPathHelper {
4850

@@ -68,22 +70,29 @@ public class UrlPathHelper {
6870

6971

7072
/**
71-
* Set if URL lookup should always use full path within current servlet
72-
* context. Else, the path within the current servlet mapping is used
73-
* if applicable (i.e. in the case of a ".../*" servlet mapping in web.xml).
74-
* Default is "false".
73+
* Whether URL lookups should always use the full path within the current
74+
* web application context, i.e. within
75+
* {@link javax.servlet.ServletContext#getContextPath()}.
76+
* <p>If set to {@literal false} the path within the current servlet mapping
77+
* is used instead if applicable (i.e. in the case of a prefix based Servlet
78+
* mapping such as "/myServlet/*").
79+
* <p>By default this is set to "false".
7580
*/
7681
public void setAlwaysUseFullPath(boolean alwaysUseFullPath) {
7782
this.alwaysUseFullPath = alwaysUseFullPath;
7883
}
7984

8085
/**
81-
* Set if context path and request URI should be URL-decoded.
82-
* Both are returned <i>undecoded</i> by the Servlet API,
83-
* in contrast to the servlet path.
84-
* <p>Uses either the request encoding or the default encoding according
85-
* to the Servlet spec (ISO-8859-1).
86-
* <p>Default is "true", as of Spring 2.5.
86+
* Whether the context path and request URI should be decoded -- both of
87+
* which are returned <i>undecoded</i> by the Servlet API, in contrast to
88+
* the servlet path.
89+
* <p>Either the request encoding or the default Servlet spec encoding
90+
* (ISO-8859-1) is used when set to "true".
91+
* <p>By default this is set to {@literal true}.
92+
* <p><strong>Note:</strong> Be aware the servlet path will not match when
93+
* compared to encoded paths. Therefore use of {@code urlDecode=false} is
94+
* not compatible with a prefix-based Servlet mapping and likewise implies
95+
* also setting {@code alwaysUseFullPath=true}.
8796
* @see #getServletPath
8897
* @see #getContextPath
8998
* @see #getRequestUri
@@ -149,8 +158,8 @@ protected String getDefaultEncoding() {
149158
* <p>Detects include request URL if called within a RequestDispatcher include.
150159
* @param request current HTTP request
151160
* @return the lookup path
152-
* @see #getPathWithinApplication
153161
* @see #getPathWithinServletMapping
162+
* @see #getPathWithinApplication
154163
*/
155164
public String getLookupPathForRequest(HttpServletRequest request) {
156165
// Always use full path within current servlet context?
@@ -179,6 +188,7 @@ public String getLookupPathForRequest(HttpServletRequest request) {
179188
* <p>E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".
180189
* @param request current HTTP request
181190
* @return the path within the servlet mapping, or ""
191+
* @see #getLookupPathForRequest
182192
*/
183193
public String getPathWithinServletMapping(HttpServletRequest request) {
184194
String pathWithinApp = getPathWithinApplication(request);
@@ -226,6 +236,7 @@ public String getPathWithinServletMapping(HttpServletRequest request) {
226236
* <p>Detects include request URL if called within a RequestDispatcher include.
227237
* @param request current HTTP request
228238
* @return the path within the web application
239+
* @see #getLookupPathForRequest
229240
*/
230241
public String getPathWithinApplication(HttpServletRequest request) {
231242
String contextPath = getContextPath(request);
@@ -279,7 +290,7 @@ else if (index1 == requestUri.length()) {
279290
/**
280291
* Sanitize the given path with the following rules:
281292
* <ul>
282-
* <li>replace all "//" by "/"</li>
293+
* <li>replace all "//" by "/"</li>
283294
* </ul>
284295
*/
285296
private String getSanitizedPath(final String path) {

0 commit comments

Comments
 (0)