Skip to content

Commit

Permalink
Apply getInterfaceMethodIfPossible without SecurityManager as well
Browse files Browse the repository at this point in the history
Closes gh-23323
  • Loading branch information
jhoeller committed Jul 20, 2019
1 parent 209c850 commit 4a09b32
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1882,10 +1882,9 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe
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;
Expand All @@ -1901,8 +1900,8 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe
}
else {
try {
ReflectionUtils.makeAccessible(initMethod);
initMethod.invoke(bean);
ReflectionUtils.makeAccessible(methodToInvoke);
methodToInvoke.invoke(bean);
}
catch (InvocationTargetException ex) {
throw ex.getTargetException();
Expand Down

0 comments on commit 4a09b32

Please sign in to comment.