From 3a2e76f5884a8190a1f6a1c5cba72463d5b7415d Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 2 Oct 2019 13:01:19 +0200 Subject: [PATCH] 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 --- .../async/ExecutorBeanPostProcessor.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/ExecutorBeanPostProcessor.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/ExecutorBeanPostProcessor.java index 68d99bd23..2da89a861 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/ExecutorBeanPostProcessor.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/async/ExecutorBeanPostProcessor.java @@ -282,13 +282,21 @@ class ExecutorBeanPostProcessor implements BeanPostProcessor { } private static boolean anyFinalMethods(T object, Class 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; }