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
DefaultAopProxyFactory: Make configurable, which interfaces are not considered user supplied. To better support code instrumentation from tools like Cobertura. [SPR-8877] #13518
in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
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:
set proxy-target-class to true or
always use interfaces
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
either a System Property to configure the interfaces to be ignored by DefaultAopProxyFactory
or a way to set a custom AopProxyFactory "globally" in the application context.
in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
Activity
spring-projects-issues commentedon Dec 27, 2018
Sébastien Deleuze commented
Closing groups of outdated issues. Please reopen if still relevant.