Describe the bug
I am using spring-cloud-sleuth-instrumentation-3.1.5.jar in combination with spring-aop-5.3.24.jar
The method callMethodOnWrappedObject(ProceedingJoinPoint pjp, T target) invokes a method to access a sessionRepository.
But it doesn't handle the case properly, when the invoked method throws a RuntimeException or another declared Exception.
The result of this bug is, that a org.springframework.web.reactive.handler.WebFluxResponseStatusExceptionHandler and perhaps other places also see a java.lang.reflect.UndeclaredThrowableException instead of the actually thrown exception.
The UndeclaredThrowableException is created in https://github.com/spring-projects/spring-framework/blob/46875c91ced9387a598c3ca7eba3ed23fdb4fc63/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java#L769
because the called sessionRepository method doesn't declare to throw an InvocationTargetException (which is correct).
Current implementation:
|
return method.invoke(target, pjp.getArgs()); |
Suggested implementation:
try {
return method.invoke(target, pjp.getArgs());
} catch(InvocationTargetException ex) {
throw ex.getCause();
}
similar to https://github.com/spring-projects/spring-framework/blob/46875c91ced9387a598c3ca7eba3ed23fdb4fc63/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java#L640
or you use org.springframework.util.ReflectionUtils.invokeMethod.
I found a similar issue #1092. Maybe there are more like this.
Describe the bug
I am using spring-cloud-sleuth-instrumentation-3.1.5.jar in combination with spring-aop-5.3.24.jar
The method
callMethodOnWrappedObject(ProceedingJoinPoint pjp, T target)invokes a method to access a sessionRepository.But it doesn't handle the case properly, when the invoked method throws a
RuntimeExceptionor another declared Exception.The result of this bug is, that a
org.springframework.web.reactive.handler.WebFluxResponseStatusExceptionHandlerand perhaps other places also see ajava.lang.reflect.UndeclaredThrowableExceptioninstead of the actually thrown exception.The
UndeclaredThrowableExceptionis created in https://github.com/spring-projects/spring-framework/blob/46875c91ced9387a598c3ca7eba3ed23fdb4fc63/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java#L769because the called sessionRepository method doesn't declare to throw an
InvocationTargetException(which is correct).Current implementation:
spring-cloud-sleuth/spring-cloud-sleuth-instrumentation/src/main/java/org/springframework/cloud/sleuth/instrument/session/TraceSessionRepositoryAspect.java
Line 82 in 8302481
Suggested implementation:
similar to https://github.com/spring-projects/spring-framework/blob/46875c91ced9387a598c3ca7eba3ed23fdb4fc63/spring-aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java#L640
or you use org.springframework.util.ReflectionUtils.invokeMethod.
I found a similar issue #1092. Maybe there are more like this.