Skip to content

Commit 3276467

Browse files
committed
wrap advice in a try/catch
1 parent 9f4aaa8 commit 3276467

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

dd-java-agent/instrumentation/grpc-1.5/src/main/java/datadog/trace/instrumentation/grpc/server/MethodHandlersInstrumentation.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,20 @@ public static class BuildAdvice {
5050

5151
@Advice.OnMethodEnter(suppress = Throwable.class)
5252
public static void onEnter(@Advice.Argument(0) Object serviceImpl) {
53-
Class<?> serviceClass = serviceImpl.getClass();
54-
Class<?> superclass = serviceClass.getSuperclass();
55-
if (superclass != null) {
56-
for (Method method : superclass.getDeclaredMethods()) {
57-
try {
58-
entry(serviceClass.getDeclaredMethod(method.getName(), method.getParameterTypes()));
59-
} catch (Throwable e) {
60-
// service method not overridden on the impl. skipping instrumentation.
53+
try {
54+
Class<?> serviceClass = serviceImpl.getClass();
55+
Class<?> superclass = serviceClass.getSuperclass();
56+
if (superclass != null) {
57+
for (Method method : superclass.getDeclaredMethods()) {
58+
try {
59+
entry(serviceClass.getDeclaredMethod(method.getName(), method.getParameterTypes()));
60+
} catch (Throwable e) {
61+
// service method not overridden on the impl. skipping instrumentation.
62+
}
6163
}
6264
}
65+
} catch (Throwable e) {
66+
// this should be logged somehow
6367
}
6468
}
6569
}

0 commit comments

Comments
 (0)