Skip to content

Commit 8ea3aa5

Browse files
committed
Merge branch '5.1.x'
2 parents 69d3e89 + 0d37209 commit 8ea3aa5

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,10 +1895,9 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe
18951895
if (logger.isTraceEnabled()) {
18961896
logger.trace("Invoking init method '" + initMethodName + "' on bean with name '" + beanName + "'");
18971897
}
1898+
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod);
18981899

18991900
if (System.getSecurityManager() != null) {
1900-
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod);
1901-
19021901
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
19031902
ReflectionUtils.makeAccessible(methodToInvoke);
19041903
return null;
@@ -1914,8 +1913,8 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe
19141913
}
19151914
else {
19161915
try {
1917-
ReflectionUtils.makeAccessible(initMethod);
1918-
initMethod.invoke(bean);
1916+
ReflectionUtils.makeAccessible(methodToInvoke);
1917+
methodToInvoke.invoke(bean);
19191918
}
19201919
catch (InvocationTargetException ex) {
19211920
throw ex.getTargetException();

spring-context/src/main/java/org/springframework/context/MessageSource.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 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.
@@ -26,10 +26,10 @@
2626
*
2727
* <p>Spring provides two out-of-the-box implementations for production:
2828
* <ul>
29-
* <li>{@link org.springframework.context.support.ResourceBundleMessageSource},
30-
* built on top of the standard {@link java.util.ResourceBundle}
31-
* <li>{@link org.springframework.context.support.ReloadableResourceBundleMessageSource},
32-
* being able to reload message definitions without restarting the VM
29+
* <li>{@link org.springframework.context.support.ResourceBundleMessageSource}: built
30+
* on top of the standard {@link java.util.ResourceBundle}, sharing its limitations.
31+
* <li>{@link org.springframework.context.support.ReloadableResourceBundleMessageSource}:
32+
* highly configurable, in particular with respect to reloading message definitions.
3333
* </ul>
3434
*
3535
* @author Rod Johnson
@@ -41,30 +41,34 @@ public interface MessageSource {
4141

4242
/**
4343
* Try to resolve the message. Return default message if no message was found.
44-
* @param code the code to lookup up, such as 'calculator.noRateSet'. Users of
45-
* this class are encouraged to base message names on the relevant fully
46-
* qualified class name, thus avoiding conflict and ensuring maximum clarity.
44+
* @param code the code to lookup up, e.g. 'calculator.noRateSet'.
45+
* MessageSource users are encouraged to base message names on qualified class
46+
* or package names, avoiding potential conflicts and ensuring maximum clarity.
4747
* @param args an array of arguments that will be filled in for params within
4848
* the message (params look like "{0}", "{1,date}", "{2,time}" within a message),
49-
* or {@code null} if none.
49+
* or {@code null} if none
5050
* @param defaultMessage a default message to return if the lookup fails
5151
* @param locale the locale in which to do the lookup
52-
* @return the resolved message if the lookup was successful;
53-
* otherwise the default message passed as a parameter
52+
* @return the resolved message if the lookup was successful, otherwise
53+
* the default message passed as a parameter (which may be {@code null})
54+
* @see #getMessage(MessageSourceResolvable, Locale)
5455
* @see java.text.MessageFormat
5556
*/
5657
@Nullable
5758
String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale);
5859

5960
/**
6061
* Try to resolve the message. Treat as an error if the message can't be found.
61-
* @param code the code to lookup up, such as 'calculator.noRateSet'
62+
* @param code the code to lookup up, e.g. 'calculator.noRateSet'.
63+
* MessageSource users are encouraged to base message names on qualified class
64+
* or package names, avoiding potential conflicts and ensuring maximum clarity.
6265
* @param args an array of arguments that will be filled in for params within
6366
* the message (params look like "{0}", "{1,date}", "{2,time}" within a message),
64-
* or {@code null} if none.
67+
* or {@code null} if none
6568
* @param locale the locale in which to do the lookup
66-
* @return the resolved message
67-
* @throws NoSuchMessageException if the message wasn't found
69+
* @return the resolved message (never {@code null})
70+
* @throws NoSuchMessageException if no corresponding message was found
71+
* @see #getMessage(MessageSourceResolvable, Locale)
6872
* @see java.text.MessageFormat
6973
*/
7074
String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException;
@@ -76,9 +80,15 @@ public interface MessageSource {
7680
* since at the time of calling this method we aren't able to determine if the
7781
* {@code defaultMessage} property of the resolvable is {@code null} or not.
7882
* @param resolvable the value object storing attributes required to resolve a message
83+
* (may include a default message)
7984
* @param locale the locale in which to do the lookup
80-
* @return the resolved message
81-
* @throws NoSuchMessageException if the message wasn't found
85+
* @return the resolved message (never {@code null} since even a
86+
* {@code MessageSourceResolvable}-provided default message needs to be non-null)
87+
* @throws NoSuchMessageException if no corresponding message was found
88+
* (and no default message was provided by the {@code MessageSourceResolvable})
89+
* @see MessageSourceResolvable#getCodes()
90+
* @see MessageSourceResolvable#getArguments()
91+
* @see MessageSourceResolvable#getDefaultMessage()
8292
* @see java.text.MessageFormat
8393
*/
8494
String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException;

spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ public void forRawClassWithNull() throws Exception {
134134
assertThat(type.isAssignableFrom(String.class)).isTrue();
135135
}
136136

137-
@Test
138-
public void forRawClassAssignableFromTypeVariable() { // gh-23321
137+
@Test // gh-23321
138+
public void forRawClassAssignableFromTypeVariable() throws Exception {
139139
ResolvableType typeVariable = ResolvableType.forClass(ExtendsList.class).as(List.class).getGeneric();
140140
ResolvableType raw = ResolvableType.forRawClass(CharSequence.class);
141141
assertThat(raw.resolve()).isEqualTo(CharSequence.class);
@@ -442,12 +442,8 @@ public void getInterfaces() throws Exception {
442442
interfaces.add(interfaceType.toString());
443443
}
444444
assertThat(interfaces.toString()).isEqualTo(
445-
"["
446-
+ "java.io.Serializable, "
447-
+ "java.lang.Cloneable, "
448-
+ "java.util.List<java.lang.CharSequence>, "
449-
+ "java.util.RandomAccess"
450-
+ "]");
445+
"[java.io.Serializable, java.lang.Cloneable, " +
446+
"java.util.List<java.lang.CharSequence>, java.util.RandomAccess]");
451447
}
452448

453449
@Test

0 commit comments

Comments
 (0)