Skip to content

Commit 4a09b32

Browse files
committed
Apply getInterfaceMethodIfPossible without SecurityManager as well
Closes gh-23323
1 parent 209c850 commit 4a09b32

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
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
@@ -1882,10 +1882,9 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe
18821882
if (logger.isTraceEnabled()) {
18831883
logger.trace("Invoking init method '" + initMethodName + "' on bean with name '" + beanName + "'");
18841884
}
1885+
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod);
18851886

18861887
if (System.getSecurityManager() != null) {
1887-
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod);
1888-
18891888
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
18901889
ReflectionUtils.makeAccessible(methodToInvoke);
18911890
return null;
@@ -1901,8 +1900,8 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe
19011900
}
19021901
else {
19031902
try {
1904-
ReflectionUtils.makeAccessible(initMethod);
1905-
initMethod.invoke(bean);
1903+
ReflectionUtils.makeAccessible(methodToInvoke);
1904+
methodToInvoke.invoke(bean);
19061905
}
19071906
catch (InvocationTargetException ex) {
19081907
throw ex.getTargetException();

0 commit comments

Comments
 (0)