You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mixed use BeanNameAutoProxyCreator and AnnotationAwareAspectJAutoProxyCreator to proxy same bean [SPR-16677] #21218
Do the #21216 changes make a difference for your scenario already, as long as you're using CGLIB proxies? You could try the latest 5.0.5.BUILD-SNAPSHOT to find out.
The user class enforcement in AopUtils was primarily motivated by runtime-generated configuration classes and not by proxies...but might help for proxy scenarios as well. And if it does help there, we should indeed consider interface-based double-proxying scenarios as well.
I've resolved this through ignoring proxy classes in AopUtils.getMostSpecificMethod, always returning a user-level method handle there. This same change also goes nicely with #21216, allowing it to expose the actual target class to MethodMatcher implementations still... just iterating over the user-class methods right away in order to avoid the superclass traversal.
As for double-proxying with interface proxies, this is generally a much tougher issue since semantically the inner proxy needs to expose the corresponding metadata to the next level... and AspectJ annotation pointcuts do not really support interface-based matching to begin with. I recommend the use of target-class proxies for such scenarios for the time being.
Thanks for your reply! I can't get the latest 5.0.5.BUILD-SNAPSHOT in maven repo to find out. So I have reviewed the commit . As for my scenario ( double-proxying the target class), I found the crucial code
publicstaticMethodgetMostSpecificMethod(Methodmethod, @NullableClass<?> targetClass) {
Class<?> specificTargetClass = (targetClass != null && !Proxy.isProxyClass(targetClass) ?
ClassUtils.getUserClass(targetClass) : null);
MethodresolvedMethod = ClassUtils.getMostSpecificMethod(method, specificTargetClass);
// If we are dealing with method with generic parameters, find the original method. returnBridgeMethodResolver.findBridgedMethod(resolvedMethod);
}
If the targetClass is a proxy class generated by CGLIB, then you will use the user class to find the bridged method. So if the annotation is present in the target class (implementation not the interface), the BeanNameAutoProxyCreator and AnnotationAwareAspectJAutoProxyCreator can work together (event thought we can not decide the execution order of the two aspect ).
Thanks for your excellent work!
Activity
spring-projects-issues commentedon Apr 2, 2018
Juergen Hoeller commented
Do the #21216 changes make a difference for your scenario already, as long as you're using CGLIB proxies? You could try the latest
5.0.5.BUILD-SNAPSHOTto find out.The user class enforcement in
AopUtilswas primarily motivated by runtime-generated configuration classes and not by proxies...but might help for proxy scenarios as well. And if it does help there, we should indeed consider interface-based double-proxying scenarios as well.spring-projects-issues commentedon Apr 3, 2018
Juergen Hoeller commented
I've resolved this through ignoring proxy classes in
AopUtils.getMostSpecificMethod, always returning a user-level method handle there. This same change also goes nicely with #21216, allowing it to expose the actual target class toMethodMatcherimplementations still... just iterating over the user-class methods right away in order to avoid the superclass traversal.As for double-proxying with interface proxies, this is generally a much tougher issue since semantically the inner proxy needs to expose the corresponding metadata to the next level... and AspectJ annotation pointcuts do not really support interface-based matching to begin with. I recommend the use of target-class proxies for such scenarios for the time being.
spring-projects-issues commentedon Apr 3, 2018
David commented
Thanks for your reply! I can't get the latest 5.0.5.BUILD-SNAPSHOT in maven repo to find out. So I have reviewed the commit . As for my scenario ( double-proxying the target class), I found the crucial code
If the targetClass is a proxy class generated by CGLIB, then you will use the user class to find the bridged method. So if the annotation is present in the target class (implementation not the interface), the BeanNameAutoProxyCreator and AnnotationAwareAspectJAutoProxyCreator can work together (event thought we can not decide the execution order of the two aspect ).
Thanks for your excellent work!