-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
MethodValidationPostProcessor validates FactoryBean methods for which validation is not applicable [SPR-17374] #21907
Comments
Juergen Hoeller commented Our |
Andy Wilkinson commented I had a hunch that would be the case. It would seem odd to check for validation annotations as there'd then be some duplication of that effort in the cases where the validator is then called. I think that skipping the methods declared on the |
Juergen Hoeller commented
|
Andy Wilkinson commented Unfortunately, the change hasn't fixed the problem as the |
Juergen Hoeller commented I was able to reproduce a kind of stack overflow in a unit test ( Are there any extra calls to |
Andy Wilkinson commented Boot need not be involved at all. You can reproduce the failure with Framework 5.0.10.RELEASE using the sample I originally provided and adding |
Juergen Hoeller commented Ouch, I thought my unit test did mirror your sample... but there's one key difference: You're using Unfortunately the CGLIB case incurs a significantly more expensive runtime check since we have to individually check for |
Juergen Hoeller commented I've created #21919 as a follow-up for the CGLIB case. |
Andy Wilkinson opened SPR-17374 and commented
Please see the referenced Spring Boot issue for some background. I've also attached a sample project that reproduces the StackOverflowError that's caused by an attempt to validate a factory bean's
getObjectType()
method while trying to retrieve theValidator
from the context due to the validator being@Lazy
.As described in the Boot issue, my investigation of the problem has led me to wonder if
MethodValidationPostProcessor
is doing more than it should. In this particular case, theFactoryBean
is annotated with@Validated
but itsgetObjectType()
method is not annotated with any validation annotations. As such, I would not expect a call to that method to attempt to use theValidator
which, due to its laziness, then triggers an attempt to retrieve theValidator
from the context which causes the factory bean'sgetObjectType()
method to be called again.Affects: 4.3.19, 5.0.9, 5.1 GA
Reference URL: spring-projects/spring-boot#13922
Attachments:
Issue Links:
Backported to: 5.0.10, 4.3.20
The text was updated successfully, but these errors were encountered: