Not throwing exception when reflection utils can't access a method

without this change when ReflectionUtils are having a problem with accessing method (cause it's private), an exception is thrown and wrapping of an executor will not take place
with this change we catch such an exception and ignore it

related to gh-1453
This commit is contained in:
Marcin Grzejszczak
2019-10-02 13:01:19 +02:00
parent 2b6b07374c
commit 3a2e76f588

View File

@@ -282,13 +282,21 @@ class ExecutorBeanPostProcessor implements BeanPostProcessor {
}
private static <T> boolean anyFinalMethods(T object, Class<T> iface) {
for (Method method : ReflectionUtils.getDeclaredMethods(iface)) {
Method m = ReflectionUtils.findMethod(object.getClass(), method.getName(),
method.getParameterTypes());
if (m != null && Modifier.isFinal(m.getModifiers())) {
return true;
try {
for (Method method : ReflectionUtils.getDeclaredMethods(iface)) {
Method m = ReflectionUtils.findMethod(object.getClass(), method.getName(),
method.getParameterTypes());
if (m != null && Modifier.isFinal(m.getModifiers())) {
return true;
}
}
}
catch (IllegalAccessError er) {
if (log.isDebugEnabled()) {
log.debug("Error occurred while trying to access methods", er);
}
return false;
}
return false;
}