Skip to content

Fix late-binding bean resolution in child application contexts - #5679

Open
Ap-95671 wants to merge 1 commit into
spring-projects:mainfrom
Ap-95671:GH-5677-signed
Open

Ap-95671 wants to merge 1 commit into
spring-projects:mainfrom
Ap-95671:GH-5677-signed

Conversation

@Ap-95671

Copy link
Copy Markdown

Problem

When a child application context copies its parent's bean-factory configuration, Spring clones the autowire candidate resolver. The late-binding wrapper did not forward the BeanFactoryAware callback, so its cloned delegate kept the parent factory. Resolving a child-only scoped bean such as ItemReader<String> could then fail with NoSuchBeanDefinitionException.

Change

Implement BeanFactoryAware on the wrapper and forward the callback when the delegate supports it. This lets Spring bind each cloned delegate to its owning factory. The regression test creates two sibling contexts with a step-scoped reader of the same name and verifies that each injects its own reader and receives its own @JobParameter value.

Validation

  • The regression reproduced the reported NoSuchBeanDefinitionException on upstream. With the fix applied to current main, all 65 configuration tests passed on JDK 25.
  • Maven verification passed on JDK 25 for Core and Infrastructure, including the unit suites and selected job- and step-scope integrations. 2,608 tests passed, 72 were skipped, and there were zero failures or errors. Formatting validation and compiler static checks passed.

AI disclosure

Codex assisted with diagnosis, implementation, tests, and drafting this description. The contributor reviewed the patch and authorized submission.

Closes #5677.

Forward the BeanFactoryAware callback to the wrapped resolver so a child context resolves its own scoped beans and job parameters.

Assisted-by: Codex
Signed-off-by: Abhishek Prajapati <215712201+Ap-95671@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

LateBindingAutowireCandidateResolver fails to resolve beans from child job application contexts

1 participant