Browse Source

Apply getInterfaceMethodIfPossible without SecurityManager as well

Closes gh-23323
pull/23837/head
Juergen Hoeller 5 years ago
parent
commit
4a09b323b6
  1. 7
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java

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

@ -1882,10 +1882,9 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -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<Object>) () -> {
ReflectionUtils.makeAccessible(methodToInvoke);
return null;
@ -1901,8 +1900,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -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();

Loading…
Cancel
Save