Only invoke getInterfaceMethodIfPossible() when security manager is used
Prior to this commit, AbstractAutowireCapableBeanFactory's invokeCustomInitMethod() method invoked ClassUtils.getInterfaceMethodIfPossible() even if the security manager was not being used. This commit ensures that getInterfaceMethodIfPossible() is only invoked if the security manager is used. Closes gh-23323
This commit is contained in:
parent
a244675630
commit
f92b60c08f
|
@ -1882,9 +1882,10 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
|
|||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Invoking init method '" + initMethodName + "' on bean with name '" + beanName + "'");
|
||||
}
|
||||
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod);
|
||||
|
||||
if (System.getSecurityManager() != null) {
|
||||
Method methodToInvoke = ClassUtils.getInterfaceMethodIfPossible(initMethod);
|
||||
|
||||
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
|
||||
ReflectionUtils.makeAccessible(methodToInvoke);
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue