diff --git a/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java b/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java index c249ca3fcf..e5d4d83850 100644 --- a/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java +++ b/spring-context-support/src/main/java/org/springframework/mail/SimpleMailMessage.java @@ -24,7 +24,8 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** - * Models a simple mail message, including data such as the from, to, cc, subject, and text fields. + * Models a simple mail message, including data such as the from, to, cc, subject, + * and text fields. * *

Consider {@code JavaMailSender} and JavaMail {@code MimeMessages} for creating * more sophisticated messages, for example messages with attachments, special @@ -179,10 +180,9 @@ public class SimpleMailMessage implements MailMessage, Serializable { /** * Copy the contents of this message to the given target message. * @param target the {@code MailMessage} to copy to - * @throws IllegalArgumentException if the supplied {@code target} is {@code null} */ public void copyTo(MailMessage target) { - Assert.notNull(target, "The 'target' message argument cannot be null"); + Assert.notNull(target, "'target' message argument must not be null"); if (getFrom() != null) { target.setFrom(getFrom()); } diff --git a/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java index 5b864c3e83..91310213c8 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -210,6 +210,39 @@ public class ResourceBundleMessageSourceTests { assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH)); } + @Test + public void testDefaultApplicationContextMessageSourceWithParent() { + GenericApplicationContext ac = new GenericApplicationContext(); + GenericApplicationContext parent = new GenericApplicationContext(); + parent.refresh(); + ac.setParent(parent); + ac.refresh(); + assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH)); + assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH)); + } + + @Test + public void testStaticApplicationContextMessageSourceWithStaticParent() { + StaticApplicationContext ac = new StaticApplicationContext(); + StaticApplicationContext parent = new StaticApplicationContext(); + parent.refresh(); + ac.setParent(parent); + ac.refresh(); + assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH)); + assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH)); + } + + @Test + public void testStaticApplicationContextMessageSourceWithDefaultParent() { + StaticApplicationContext ac = new StaticApplicationContext(); + GenericApplicationContext parent = new GenericApplicationContext(); + parent.refresh(); + ac.setParent(parent); + ac.refresh(); + assertEquals("default", ac.getMessage("code1", null, "default", Locale.ENGLISH)); + assertEquals("default value", ac.getMessage("code1", new Object[] {"value"}, "default {0}", Locale.ENGLISH)); + } + @Test public void testResourceBundleMessageSourceStandalone() { ResourceBundleMessageSource ms = new ResourceBundleMessageSource(); diff --git a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java index 668a4b5cf3..ceb9567194 100644 --- a/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/StandardAnnotationMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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. @@ -150,7 +150,7 @@ public class StandardAnnotationMetadata extends StandardClassMetadata implements public Set getAnnotatedMethods(String annotationName) { try { Method[] methods = getIntrospectedClass().getDeclaredMethods(); - Set annotatedMethods = new LinkedHashSet(); + Set annotatedMethods = new LinkedHashSet(4); for (Method method : methods) { if (!method.isBridge() && method.getAnnotations().length > 0 && AnnotatedElementUtils.isAnnotated(method, annotationName)) { diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java index 9dfcfd1a82..d3f6e3004a 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 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. @@ -77,12 +77,13 @@ public class MethodMetadataReadingVisitor extends MethodVisitor implements Metho @Override public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { - String className = Type.getType(desc).getClassName(); this.methodMetadataSet.add(this); + String className = Type.getType(desc).getClassName(); return new AnnotationAttributesReadingVisitor( className, this.attributesMap, this.metaAnnotationMap, this.classLoader); } + @Override public String getMethodName() { return this.methodName;