diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 1fe4f2ebc1..c11bce1865 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -1882,10 +1882,9 @@ 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) () -> { ReflectionUtils.makeAccessible(methodToInvoke); return null; @@ -1901,8 +1900,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac } else { try { - ReflectionUtils.makeAccessible(initMethod); - initMethod.invoke(bean); + ReflectionUtils.makeAccessible(methodToInvoke); + methodToInvoke.invoke(bean); } catch (InvocationTargetException ex) { throw ex.getTargetException();