DefaultAopProxyFactory: Make configurable, which interfaces are not considered user supplied. To better support code instrumentation from tools like Cobertura. [SPR-8877] #13518
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: declined
A suggestion or change that we don't feel we should currently apply
type: enhancement
A general enhancement
Stefan Ocke opened SPR-8877 and commented
The current behavior of DefaultAopProxyFactory is to use dynamic proxy if the target has any interface other than SpringProxy. Only if the class has no interface, CGLIB is used.
When using Cobertura to measure code coverage, some instrumentation is applied to the beans. Especially, a marker interface is introduced.
This changes the behavior of Spring AOP in the way, that in places, where CGLIB was used before, dynamic proxy is used. The results are injection errors, since the proxy is not of appropriate type (... the type of the target class is required).
Looking for solutions, I found the following suggestions:
However, in exisiting large projects, both of these solutions might imply a lot of changes and thus might not be applicable.
It would help, if there was a way to configure DefaultAopProxyFactory to not only ignore SpringProxy but also other interfaces (f.e. Cobertura marker interfaces) when making its CGLIB / dynamic proxy decision.
Currently, there is no easy way to to this. While it ist possible to configure the AopProxyFactory to be used in a ProxyFactory(Bean), there are many places in Spring code, where ProxyFactory is created by new() operator and there is no chance to set the AopProxyFactory.
Thus I would suggest
Issue Links:
The text was updated successfully, but these errors were encountered: