Browse Source

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
pull/23837/head
zheng.ren01@mljr.com 5 years ago committed by Sam Brannen
parent
commit
f92b60c08f
  1. 3
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

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

@ -1882,9 +1882,10 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -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…
Cancel
Save