Skip to content

@Transactional beans not getting proxied when being initialized during failed circular reference attempt #22370

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
laoseth opened this issue Feb 7, 2019 · 2 comments
Assignees
Labels
status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@laoseth
Copy link

laoseth commented Feb 7, 2019

Currently using spring 4.3.22.RELEASE

Working in a large project with a bunch of circular preferences. When creating the bean structure, if bean creation fails initially(seeing a beanCreationException due to a failed ProxyBean creation without a known target class), the entire dependency graph of failed bean creations is rolled back. In our case, this includes our proxied @ Transactional bean. When the bean graph creation continues down a different, eventually successful path, the @ Transactional bean is recreated. However, during the original rollback, InfrastructureAdvisorAutoProxyCreator (extending AbstractAutoProxyCreator) isn't informed, so it's copy of earlyProxyReferences isn't informed that the early bean creation from earlier is gone, so when org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(Object, String) is called, it does not call wrapIfNecessary, as earlyProxyReferences still contains the bean name, from when it fails the first time.

Note, that if the circular reference causes a failure only once, this doesn't seem to happen, but if there are 2 failures, it seems to start returning unproxied beans. It appears to be the case that we have to be trying to wire the @ transactional bean into a bean in a different context for this to happen. It should be noted spring ends up initializing, just with missing proxies, which is almost worse than just failing, as the app comes up in an unknown state

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 7, 2019
@jhoeller jhoeller self-assigned this Feb 7, 2019
@jhoeller jhoeller added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 7, 2019
@jhoeller jhoeller added this to the 5.1.5 milestone Feb 7, 2019
@jhoeller jhoeller changed the title @Transactional beans not being proxied if a BeanInCreationException is thrown while being initalized while spring working through a circular reference @Transactional beans not getting proxied when being initialized during failed circular reference attempt Feb 7, 2019
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.0.x labels Feb 7, 2019
jhoeller added a commit that referenced this issue Feb 7, 2019
@jhoeller
Copy link
Contributor

This is available in 5.1.5.BUILD-SNAPSHOT from https://repo.spring.io/snapshot now. Feel free to give it an early try before the official 5.1.5 release on Wednesday...

It's also available in 4.3.23.BUILD-SNAPSHOT in case you'd like that branch a try. However, please note that the official 4.3.23 release is only scheduled for late March.

@laoseth
Copy link
Author

laoseth commented Feb 15, 2019

Thank you for this fixed. It appears to have fixed the creation of non-proxied beans. We had some other issues behind it that have kept us from verifying it 100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants