Skip to content
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

Self autowiring does not work for transactional beans [SPR-16645] #21186

Closed
spring-projects-issues opened this issue Mar 26, 2018 · 2 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: invalid An issue that we don't feel is valid

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 26, 2018

Jon Rimmer opened SPR-16645 and commented

The ability for beans to self autowire was added in: #13096

However, this does not work if the bean to self wire is transactional, e.g. has at least one method annotated with @transactional when transactions are enabled.

See the linked GitHub project for a very simple reproduction.


Affects: 5.0.4

Reference URL: https://github.com/jonrimmer/spring-self-autowiring-is-broken

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 26, 2018

Juergen Hoeller commented

From a quick look at your sample, it looks you're dereferencing a nested field on the self-injected service proxy: That won't work since you'll get a CGLIB proxy with uninitialized fields that you're not supposed to access on the proxy instance. You have to go through public non-final methods there which the proxy can actually intercept.

That said, why are you even dereferencing that field on the proxy to begin with? Only the service proxy itself has transactionally decorated methods: If you're calling methods on a nested delegate there, those won't be transactional in any case. Or am I missing something?

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Mar 26, 2018

Jon Rimmer commented

Ah, yes. I see now. The non-sample code was calling a method on the injected self reference, but it wasn't public, so wasn't proxied. Sorry!

@spring-projects-issues spring-projects-issues added type: bug A general bug status: invalid An issue that we don't feel is valid in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues removed the type: bug A general bug label Jan 12, 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: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

2 participants