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

When a parent context has method validation configuration, it isn't auto-configured in its child contexts #27890

Closed
cmercer opened this issue Sep 8, 2021 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@cmercer
Copy link

cmercer commented Sep 8, 2021

Summary:

ValidationAutoConfiguration.methodValidationPostProcessor should have @ConditionalOnMissingBean(search = SearchStrategy.CURRENT)

Demo code: https://github.com/cmercer/spring-boot-validation-issue
The above code has a fix enabled by default, readme contains information about reenabling the break.

Details:
One of my project has a rather complicated deployment which spiders out application contexts somewhat like the following.

  • parent
    • web1 parent
      • web1
    • web2 parent
      • web2
    • web3 parent
      • web3

One of the things I found is method validation would not work correctly in our web apps.
I think this is because BeanPostProcessors are only applied when they are in the current application context and not from the parent context (which makes senses). But ValidationAutoConfiguration.methodValidationPostProcessor finds that the it already exists in the parent context and does not create it in the child context.

This not only effected controllers, but also any Bean that might have any validation on its methods, such as NotNull, NotBlank etc.

The demo app above is against 2.5.4, but this issue exists at least back to 2.3.9.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 8, 2021
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 10, 2021
@philwebb philwebb added this to the 2.4.x milestone Sep 10, 2021
@wilkinsona wilkinsona self-assigned this Oct 29, 2021
@wilkinsona wilkinsona changed the title spring boot validation and parent contexts When a parent context has method validation configuration, it isn't auto-configured in its child contexts Oct 29, 2021
@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.4.13 Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants