BeanValidationPostProcessor(afterInitialization=true) fails for cglib proxied bean [SPR-17273] #21806
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Philipp Foermer opened SPR-17273 and commented
Is
An instance of "org.springframework.validation.beanvalidation.BeanValidationPostProcessor" with property "afterInitialization=true" fails to validate a bean instance for which a cglib proxy has been created around.
Example: If a bean class declares a javax.validation.NotNull constraint for a bean property, then the validation fails on the cglib proxy instance as Spring uses delegation for proxies and the bean property is null on the cglib proxy instance.
For LegacyDao Spring creates an AOP proxy around for PersistenceExceptionTranslator, because of the Repository annotation. If LegacyDao is validated by BeanValidationPostProcessor(afterInitialization=true), then the validation fails.
Exepected behaviour
Validation performed by BeanValidationPostProcessor for a proxy instance should be done on the ultimate target object and not on intermediate proxy instances.
Affects: 4.3.17
Referenced from: commits 77887ef
The text was updated successfully, but these errors were encountered: