Skip to content

Commit

Permalink
wrap advice in a try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Nov 27, 2024
1 parent 9f4aaa8 commit 3276467
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ public static class BuildAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static void onEnter(@Advice.Argument(0) Object serviceImpl) {
Class<?> serviceClass = serviceImpl.getClass();
Class<?> superclass = serviceClass.getSuperclass();
if (superclass != null) {
for (Method method : superclass.getDeclaredMethods()) {
try {
entry(serviceClass.getDeclaredMethod(method.getName(), method.getParameterTypes()));
} catch (Throwable e) {
// service method not overridden on the impl. skipping instrumentation.
try {
Class<?> serviceClass = serviceImpl.getClass();
Class<?> superclass = serviceClass.getSuperclass();
if (superclass != null) {
for (Method method : superclass.getDeclaredMethods()) {
try {
entry(serviceClass.getDeclaredMethod(method.getName(), method.getParameterTypes()));
} catch (Throwable e) {
// service method not overridden on the impl. skipping instrumentation.
}
}
}
} catch (Throwable e) {
// this should be logged somehow
}
}
}
Expand Down

0 comments on commit 3276467

Please sign in to comment.