Skip to content

Commit 1332482

Browse files
committed
Polishing
1 parent 799589e commit 1332482

File tree

6 files changed

+46
-36
lines changed

6 files changed

+46
-36
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -42,7 +42,7 @@ public class Problem {
4242

4343
/**
4444
* Create a new instance of the {@link Problem} class.
45-
* @param message a message detailing the problem
45+
* @param message a message detailing the problem
4646
* @param location the location within a bean configuration source that triggered the error
4747
*/
4848
public Problem(String message, Location location) {
@@ -51,7 +51,7 @@ public Problem(String message, Location location) {
5151

5252
/**
5353
* Create a new instance of the {@link Problem} class.
54-
* @param message a message detailing the problem
54+
* @param message a message detailing the problem
5555
* @param parseState the {@link ParseState} at the time of the error
5656
* @param location the location within a bean configuration source that triggered the error
5757
*/
@@ -61,8 +61,8 @@ public Problem(String message, Location location, ParseState parseState) {
6161

6262
/**
6363
* Create a new instance of the {@link Problem} class.
64-
* @param message a message detailing the problem
65-
* @param rootCause the underlying expection that caused the error (may be {@code null})
64+
* @param message a message detailing the problem
65+
* @param rootCause the underlying exception that caused the error (may be {@code null})
6666
* @param parseState the {@link ParseState} at the time of the error
6767
* @param location the location within a bean configuration source that triggered the error
6868
*/
@@ -107,7 +107,7 @@ public ParseState getParseState() {
107107
}
108108

109109
/**
110-
* Get the underlying expection that caused the error (may be {@code null}).
110+
* Get the underlying exception that caused the error (may be {@code null}).
111111
*/
112112
public Throwable getRootCause() {
113113
return this.rootCause;

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,8 +1295,8 @@ protected RootBeanDefinition getMergedBeanDefinition(
12951295
mbd.setScope(containingBd.getScope());
12961296
}
12971297

1298-
// Only cache the merged bean definition if we're already about to create an
1299-
// instance of the bean, or at least have already created an instance before.
1298+
// Cache the merged bean definition for the time being
1299+
// (it might still get re-merged later on in order to pick up metadata changes)
13001300
if (containingBd == null && isCacheBeanMetadata()) {
13011301
this.mergedBeanDefinitions.put(beanName, mbd);
13021302
}

spring-core/src/main/java/org/springframework/core/io/ResourceEditor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -81,7 +81,9 @@ public ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyRe
8181
* @param ignoreUnresolvablePlaceholders whether to ignore unresolvable placeholders
8282
* if no corresponding property could be found in the given {@code propertyResolver}
8383
*/
84-
public ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyResolver, boolean ignoreUnresolvablePlaceholders) {
84+
public ResourceEditor(ResourceLoader resourceLoader, PropertyResolver propertyResolver,
85+
boolean ignoreUnresolvablePlaceholders) {
86+
8587
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
8688
this.resourceLoader = resourceLoader;
8789
this.propertyResolver = propertyResolver;

spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
* @author Sam Brannen
5555
* @author Chris Beams
5656
* @author Phillip Webb
57+
* @author Oleg Zhurakousky
5758
*/
5859
public class AnnotationUtilsTests {
5960

@@ -90,7 +91,7 @@ public void findMethodAnnotationOnLeaf() throws Exception {
9091
assertNotNull(findAnnotation(m, Order.class));
9192
}
9293

93-
/** @since 4.2 */
94+
// @since 4.2
9495
@Test
9596
public void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Exception {
9697
Method m = Leaf.class.getMethod("fromInterfaceImplementedByRoot");
@@ -102,7 +103,7 @@ public void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Excep
102103
assertNotNull(findAnnotation(m, Order.class));
103104
}
104105

105-
/** @since 4.2 */
106+
// @since 4.2
106107
@Test
107108
public void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception {
108109
Method m = Leaf.class.getMethod("metaAnnotatedOnLeaf");
@@ -111,7 +112,7 @@ public void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception {
111112
assertNotNull(findAnnotation(m, Order.class));
112113
}
113114

114-
/** @since 4.2 */
115+
// @since 4.2
115116
@Test
116117
public void findMethodAnnotationWithMetaMetaAnnotationOnLeaf() throws Exception {
117118
Method m = Leaf.class.getMethod("metaMetaAnnotatedOnLeaf");
@@ -128,7 +129,7 @@ public void findMethodAnnotationOnRoot() throws Exception {
128129
assertNotNull(findAnnotation(m, Order.class));
129130
}
130131

131-
/** @since 4.2 */
132+
// @since 4.2
132133
@Test
133134
public void findMethodAnnotationWithMetaAnnotationOnRoot() throws Exception {
134135
Method m = Leaf.class.getMethod("metaAnnotatedOnRoot");
@@ -258,42 +259,42 @@ public void findClassAnnotationOnMetaCycleAnnotatedClassWithMissingTargetMetaAnn
258259
assertNull("Should not find @Component on MetaCycleAnnotatedClass", component);
259260
}
260261

261-
/** @since 4.2 */
262+
// @since 4.2
262263
@Test
263264
public void findClassAnnotationOnInheritedAnnotationInterface() {
264265
Transactional tx = findAnnotation(InheritedAnnotationInterface.class, Transactional.class);
265266
assertNotNull("Should find @Transactional on InheritedAnnotationInterface", tx);
266267
}
267268

268-
/** @since 4.2 */
269+
// @since 4.2
269270
@Test
270271
public void findClassAnnotationOnSubInheritedAnnotationInterface() {
271272
Transactional tx = findAnnotation(SubInheritedAnnotationInterface.class, Transactional.class);
272273
assertNotNull("Should find @Transactional on SubInheritedAnnotationInterface", tx);
273274
}
274275

275-
/** @since 4.2 */
276+
// @since 4.2
276277
@Test
277278
public void findClassAnnotationOnSubSubInheritedAnnotationInterface() {
278279
Transactional tx = findAnnotation(SubSubInheritedAnnotationInterface.class, Transactional.class);
279280
assertNotNull("Should find @Transactional on SubSubInheritedAnnotationInterface", tx);
280281
}
281282

282-
/** @since 4.2 */
283+
// @since 4.2
283284
@Test
284285
public void findClassAnnotationOnNonInheritedAnnotationInterface() {
285286
Order order = findAnnotation(NonInheritedAnnotationInterface.class, Order.class);
286287
assertNotNull("Should find @Order on NonInheritedAnnotationInterface", order);
287288
}
288289

289-
/** @since 4.2 */
290+
// @since 4.2
290291
@Test
291292
public void findClassAnnotationOnSubNonInheritedAnnotationInterface() {
292293
Order order = findAnnotation(SubNonInheritedAnnotationInterface.class, Order.class);
293294
assertNotNull("Should find @Order on SubNonInheritedAnnotationInterface", order);
294295
}
295296

296-
/** @since 4.2 */
297+
// @since 4.2
297298
@Test
298299
public void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() {
299300
Order order = findAnnotation(SubSubNonInheritedAnnotationInterface.class, Order.class);
@@ -1240,6 +1241,11 @@ public void synthesizeAnnotationFromDefaultsWithAttributeAliases() throws Except
12401241
assertEquals("location: ", "", contextConfig.location());
12411242
}
12421243

1244+
@Test(expected = AnnotationConfigurationException.class)
1245+
public void synthesizeAnnotationWithAttributeAliasesDifferentValues() throws Exception {
1246+
getValue(synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class)));
1247+
}
1248+
12431249
@Test
12441250
public void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception {
12451251
Map<String, Object> map = Collections.singletonMap("location", "test.xml");
@@ -1357,11 +1363,6 @@ public void toStringForSynthesizedAnnotations() throws Exception {
13571363
assertNotNull(synthesizedWebMapping2);
13581364

13591365
assertThat(webMappingWithAliases.toString(), is(not(synthesizedWebMapping1.toString())));
1360-
1361-
// The unsynthesized annotation for handleMappedWithSamePathAndValueAttributes()
1362-
// should produce the same toString() results as synthesized annotations for
1363-
// handleMappedWithPathAttribute()
1364-
assertToStringForWebMappingWithPathAndValue(webMappingWithPathAndValue);
13651366
assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping1);
13661367
assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping2);
13671368
}
@@ -1819,13 +1820,13 @@ public void foo() {
18191820
interface InterfaceWithRepeated {
18201821

18211822
@MyRepeatable("A")
1822-
@MyRepeatableContainer({ @MyRepeatable("B"), @MyRepeatable("C") })
1823+
@MyRepeatableContainer({@MyRepeatable("B"), @MyRepeatable("C")})
18231824
@MyRepeatableMeta1
18241825
void foo();
18251826
}
18261827

18271828
@MyRepeatable("A")
1828-
@MyRepeatableContainer({ @MyRepeatable("B"), @MyRepeatable("C") })
1829+
@MyRepeatableContainer({@MyRepeatable("B"), @MyRepeatable("C")})
18291830
@MyRepeatableMeta1
18301831
static class MyRepeatableClass {
18311832
}
@@ -1834,7 +1835,7 @@ static class SubMyRepeatableClass extends MyRepeatableClass {
18341835
}
18351836

18361837
@MyRepeatable("X")
1837-
@MyRepeatableContainer({ @MyRepeatable("Y"), @MyRepeatable("Z") })
1838+
@MyRepeatableContainer({@MyRepeatable("Y"), @MyRepeatable("Z")})
18381839
@MyRepeatableMeta2
18391840
static class SubMyRepeatableWithAdditionalLocalDeclarationsClass extends MyRepeatableClass {
18401841
}
@@ -1964,7 +1965,7 @@ public void handleMappedWithDifferentPathAndValueAttributes() {
19641965
BrokenContextConfig[] value();
19651966
}
19661967

1967-
@Hierarchy({ @ContextConfig("A"), @ContextConfig(location = "B") })
1968+
@Hierarchy({@ContextConfig("A"), @ContextConfig(location = "B")})
19681969
static class ConfigHierarchyTestCase {
19691970
}
19701971

@@ -2316,7 +2317,7 @@ static class TransitiveImplicitAliasesForAliasPairContextConfigClass {
23162317
Filter[] excludeFilters() default {};
23172318
}
23182319

2319-
@ComponentScan(excludeFilters = { @Filter(pattern = "*Foo"), @Filter(pattern = "*Bar") })
2320+
@ComponentScan(excludeFilters = {@Filter(pattern = "*Foo"), @Filter(pattern = "*Bar")})
23202321
static class ComponentScanClass {
23212322
}
23222323

@@ -2344,4 +2345,8 @@ static class ComponentScanSingleFilterClass {
23442345
String text();
23452346
}
23462347

2348+
@ContextConfig(value = "foo", location = "bar")
2349+
interface ContextConfigMismatch {
2350+
}
2351+
23472352
}

spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,11 @@ private void applyDefaultCharset() {
179179
* names. Encoding is based on the encoded-word syntax defined in RFC 2047
180180
* and relies on {@code MimeUtility} from "javax.mail".
181181
* <p>If not set file names will be encoded as US-ASCII.
182-
* @param multipartCharset the charset to use
183182
* @since 4.1.1
184183
* @see <a href="http://en.wikipedia.org/wiki/MIME#Encoded-Word">Encoded-Word</a>
185184
*/
186-
public void setMultipartCharset(Charset multipartCharset) {
187-
this.multipartCharset = multipartCharset;
185+
public void setMultipartCharset(Charset charset) {
186+
this.multipartCharset = charset;
188187
}
189188

190189

spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ public class DispatcherServlet extends FrameworkServlet {
264264
*/
265265
private static final String DEFAULT_STRATEGIES_PATH = "DispatcherServlet.properties";
266266

267+
/**
268+
* Common prefix that DispatcherServlet's default strategy attributes start with.
269+
*/
270+
private static final String DEFAULT_STRATEGIES_PREFIX = "org.springframework.web.servlet";
267271

268272
/** Additional logger to use when no mapped handler is found for a request. */
269273
protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);
@@ -279,7 +283,7 @@ public class DispatcherServlet extends FrameworkServlet {
279283
defaultStrategies = PropertiesLoaderUtils.loadProperties(resource);
280284
}
281285
catch (IOException ex) {
282-
throw new IllegalStateException("Could not load 'DispatcherServlet.properties': " + ex.getMessage());
286+
throw new IllegalStateException("Could not load '" + DEFAULT_STRATEGIES_PATH + "': " + ex.getMessage());
283287
}
284288
}
285289

@@ -874,7 +878,7 @@ protected void doService(HttpServletRequest request, HttpServletResponse respons
874878
Enumeration<?> attrNames = request.getAttributeNames();
875879
while (attrNames.hasMoreElements()) {
876880
String attrName = (String) attrNames.nextElement();
877-
if (this.cleanupAfterInclude || attrName.startsWith("org.springframework.web.servlet")) {
881+
if (this.cleanupAfterInclude || attrName.startsWith(DEFAULT_STRATEGIES_PREFIX)) {
878882
attributesSnapshot.put(attrName, request.getAttribute(attrName));
879883
}
880884
}
@@ -1348,7 +1352,7 @@ private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?,?>
13481352
Enumeration<?> attrNames = request.getAttributeNames();
13491353
while (attrNames.hasMoreElements()) {
13501354
String attrName = (String) attrNames.nextElement();
1351-
if (this.cleanupAfterInclude || attrName.startsWith("org.springframework.web.servlet")) {
1355+
if (this.cleanupAfterInclude || attrName.startsWith(DEFAULT_STRATEGIES_PREFIX)) {
13521356
attrsToCheck.add(attrName);
13531357
}
13541358
}

0 commit comments

Comments
 (0)