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

Prevent setting parent bean factory to self #24900

Conversation

liuhy365
Copy link
Contributor

If set parent bean factory to self, once try to get an undefined bean,
bellow condition
if (parentBeanFactory != null && !containsBeanDefinition(beanName)) {
...
}
will always be true and StackOverflowError will be thrown.
Sometimes, this issue is hard to detect during runtime,
if self-reference is not allowed here,
error will be found at the early time of startup.
Also, a self-reference parent bean factory is valueless.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
If set parent bean factory to self, once try to get an undefined bean,  bellow condition
if (parentBeanFactory != null && !containsBeanDefinition(beanName)) {
...
}
will always be true and  StackOverflowError will be thrown.
Sometimes, this issue is hard to detect during runtime, if self-reference is not allowed here, error will be found at the early time of startup.
Also, a self-reference parent bean factory is valueless.
@pivotal-issuemaster
Copy link

@liuhy365 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 13, 2020
@pivotal-issuemaster
Copy link

@liuhy365 Thank you for signing the Contributor License Agreement!

@jhoeller jhoeller changed the title Fix parent bean factory self-reference issue. Prevent setting parent bean factory to self Apr 13, 2020
@jhoeller jhoeller self-assigned this Apr 13, 2020
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 13, 2020
@jhoeller jhoeller added this to the 5.2.6 milestone Apr 13, 2020
@jhoeller jhoeller merged commit 3af5469 into spring-projects:master Apr 25, 2020
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) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants