Skip to content

DefaultAopProxyFactory: Make configurable, which interfaces are not considered user supplied. To better support code instrumentation from tools like Cobertura. [SPR-8877] #13518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Nov 26, 2011 · 1 comment
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

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 26, 2011

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:

  • 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.

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Sébastien Deleuze commented

Closing groups of outdated issues. Please reopen if still relevant.

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

1 participant