Skip to content

Commit db7d715

Browse files
committed
Polishing
1 parent 99d39eb commit db7d715

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
import org.springframework.util.StringUtils;
2525

2626
/**
27-
* Models a simple mail message, including data such as the from, to, cc, subject, and text fields.
27+
* Models a simple mail message, including data such as the from, to, cc, subject,
28+
* and text fields.
2829
*
2930
* <p>Consider {@code JavaMailSender} and JavaMail {@code MimeMessages} for creating
3031
* more sophisticated messages, for example messages with attachments, special
@@ -179,10 +180,9 @@ public String getText() {
179180
/**
180181
* Copy the contents of this message to the given target message.
181182
* @param target the {@code MailMessage} to copy to
182-
* @throws IllegalArgumentException if the supplied {@code target} is {@code null}
183183
*/
184184
public void copyTo(MailMessage target) {
185-
Assert.notNull(target, "The 'target' message argument cannot be null");
185+
Assert.notNull(target, "'target' message argument must not be null");
186186
if (getFrom() != null) {
187187
target.setFrom(getFrom());
188188
}

spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java

Lines changed: 34 additions & 1 deletion
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.
@@ -210,6 +210,39 @@ public void testDefaultApplicationContextMessageSource() {
210210
assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH));
211211
}
212212

213+
@Test
214+
public void testDefaultApplicationContextMessageSourceWithParent() {
215+
GenericApplicationContext ac = new GenericApplicationContext();
216+
GenericApplicationContext parent = new GenericApplicationContext();
217+
parent.refresh();
218+
ac.setParent(parent);
219+
ac.refresh();
220+
assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH));
221+
assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH));
222+
}
223+
224+
@Test
225+
public void testStaticApplicationContextMessageSourceWithStaticParent() {
226+
StaticApplicationContext ac = new StaticApplicationContext();
227+
StaticApplicationContext parent = new StaticApplicationContext();
228+
parent.refresh();
229+
ac.setParent(parent);
230+
ac.refresh();
231+
assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH));
232+
assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH));
233+
}
234+
235+
@Test
236+
public void testStaticApplicationContextMessageSourceWithDefaultParent() {
237+
StaticApplicationContext ac = new StaticApplicationContext();
238+
GenericApplicationContext parent = new GenericApplicationContext();
239+
parent.refresh();
240+
ac.setParent(parent);
241+
ac.refresh();
242+
assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH));
243+
assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH));
244+
}
245+
213246
@Test
214247
public void testResourceBundleMessageSourceStandalone() {
215248
ResourceBundleMessageSource ms = new ResourceBundleMessageSource();

spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 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.
@@ -150,7 +150,7 @@ public boolean hasAnnotatedMethods(String annotationName) {
150150
public Set<MethodMetadata> getAnnotatedMethods(String annotationName) {
151151
try {
152152
Method[] methods = getIntrospectedClass().getDeclaredMethods();
153-
Set<MethodMetadata> annotatedMethods = new LinkedHashSet<MethodMetadata>();
153+
Set<MethodMetadata> annotatedMethods = new LinkedHashSet<MethodMetadata>(4);
154154
for (Method method : methods) {
155155
if (!method.isBridge() && method.getAnnotations().length > 0 &&
156156
AnnotatedElementUtils.isAnnotated(method, annotationName)) {

spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 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.
@@ -77,12 +77,13 @@ public MethodMetadataReadingVisitor(String methodName, int access, String declar
7777

7878
@Override
7979
public AnnotationVisitor visitAnnotation(final String desc, boolean visible) {
80-
String className = Type.getType(desc).getClassName();
8180
this.methodMetadataSet.add(this);
81+
String className = Type.getType(desc).getClassName();
8282
return new AnnotationAttributesReadingVisitor(
8383
className, this.attributesMap, this.metaAnnotationMap, this.classLoader);
8484
}
8585

86+
8687
@Override
8788
public String getMethodName() {
8889
return this.methodName;

0 commit comments

Comments
 (0)