Skip to content

Commit

Permalink
Only invoke getInterfaceMethodIfPossible() when security manager is used
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zheng.ren01@mljr.com authored and sbrannen committed Jul 20, 2019
1 parent a244675 commit f92b60c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1882,9 +1882,10 @@ 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 Down

0 comments on commit f92b60c

Please sign in to comment.