Skip to content

Commit

Permalink
Update AWSXRayTracingStatement.java
Browse files Browse the repository at this point in the history
  • Loading branch information
anthunt authored Jul 29, 2024
1 parent 7609e08 commit 89c0b50
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,21 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
try {
// execute the query "wrapped" in a XRay Subsegment
return method.invoke(delegate, args);
} catch (Throwable t) {
if (t instanceof InvocationTargetException) {
// the reflection may wrap the actual error with an InvocationTargetException.
// we want to use the root cause to make the instrumentation seamless
InvocationTargetException ite = (InvocationTargetException) t;
if (ite.getTargetException() != null) {
subsegment.addException(ite.getTargetException());
throw ite.getTargetException();
}
if (ite.getCause() != null) {
subsegment.addException(ite.getCause());
throw ite.getCause();
}
subsegment.addException(ite);
throw ite;
} catch (InvocationTargetException t) {
// the reflection may wrap the actual error with an InvocationTargetException.
// we want to use the root cause to make the instrumentation seamless
InvocationTargetException ite = t;
if (ite.getTargetException() != null) {
subsegment.addException(ite.getTargetException());
throw ite.getTargetException();
}

if (ite.getCause() != null) {
subsegment.addException(ite.getCause());
throw ite.getCause();
}
subsegment.addException(ite);
throw ite;
} catch (Throwable t) {
subsegment.addException(t);
throw t;
} finally {
Expand Down

0 comments on commit 89c0b50

Please sign in to comment.