Skip to content

Fix non-root namespace bean injection timing issue (#2579) #2600

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

expanded-for-real
Copy link

Fixes timing issue where non-root namespace beans were created too late in the Spring lifecycle as described in 2579. This is fixed by modifying NonRootBeanPostProcessor to trigger bean creation when the root namespace template is actually ready as opposed to triggering on any bean initialization

@expanded-for-real expanded-for-real requested a review from a team as a code owner July 17, 2025 04:25
@CLAassistant
Copy link

CLAassistant commented Jul 17, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


B. Johnson seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Quinn-With-Two-Ns
Copy link
Contributor

Hey thanks for the contribution, I will make sure to review this as soon as I can. Either today or tomorrow.

Can we make sure we test the specific scenario brought up in the issue as well #2579? Basically ensure we can inject a non-root bean like a non-root client, Thanks!

@expanded-for-real
Copy link
Author

expanded-for-real commented Jul 18, 2025

@Quinn-With-Two-Ns changing this to a draft actually while I think about it a bit more. Further testing leads me to think there might be a need for a different bean processor rather than BeanPostProcessor (perhaps BeanFactoryPostProcessor)

Updated

@expanded-for-real expanded-for-real changed the title Fix non-root namespace bean injection timing issue (#2579) Draft: Fix non-root namespace bean injection timing issue (#2579) Jul 18, 2025
@expanded-for-real
Copy link
Author

Slight change to my original proposed fix - added shouldStartSuccessfullyWithNonRootNamespaceConfiguration for verification

@Quinn-With-Two-Ns
Copy link
Contributor

@expanded-for-real I don't think shouldStartSuccessfullyWithNonRootNamespaceConfiguration really covers the case in question. I don't think this verifies that constructor or field injection would work since your just getting the beans from the application context. I think we should test those two cases explicitly

@expanded-for-real expanded-for-real changed the title Draft: Fix non-root namespace bean injection timing issue (#2579) Fix non-root namespace bean injection timing issue (#2579) Jul 18, 2025
@expanded-for-real
Copy link
Author

expanded-for-real commented Jul 21, 2025

@Quinn-With-Two-Ns I was able to create a test that basically mimicked the timing issue (which became BeanAvailabilityValidator in the NonRootNamespaceBeanAvailabilityTest class) and I think it ended up being a bit more subtle than I previously thought. I believe the original BeanPostProcessor approach was running too late in the Spring lifecycle to enable @Resource injection, but I was able to resolve it by allowing @Resource beans to be registered earlier through a ImportBeanDefinitionRegistrar implementation. The existing tests all pass with only one modification to MultiNamespaceTest but this will likely require careful review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants