File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
spring-aop/src/main/java/org/springframework/aop/framework Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 49
49
import org .springframework .cglib .proxy .MethodInterceptor ;
50
50
import org .springframework .cglib .proxy .MethodProxy ;
51
51
import org .springframework .cglib .proxy .NoOp ;
52
+ import org .springframework .core .KotlinDetector ;
52
53
import org .springframework .core .SmartClassLoader ;
53
54
import org .springframework .lang .Nullable ;
54
55
import org .springframework .util .Assert ;
@@ -752,10 +753,17 @@ public Object proceed() throws Throwable {
752
753
throw ex ;
753
754
}
754
755
catch (Exception ex ) {
755
- if (ReflectionUtils .declaresException (getMethod (), ex .getClass ())) {
756
+ if (ReflectionUtils .declaresException (getMethod (), ex .getClass ()) ||
757
+ KotlinDetector .isKotlinType (getMethod ().getDeclaringClass ())) {
758
+ // Propagate original exception if declared on the target method
759
+ // (with callers expecting it). Always propagate it for Kotlin code
760
+ // since checked exceptions do not have to be explicitly declared there.
756
761
throw ex ;
757
762
}
758
763
else {
764
+ // Checked exception thrown in the interceptor but not declared on the
765
+ // target method signature -> apply an UndeclaredThrowableException,
766
+ // aligned with standard JDK dynamic proxy behavior.
759
767
throw new UndeclaredThrowableException (ex );
760
768
}
761
769
}
You can’t perform that action at this time.
0 commit comments