You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A ConstraintValidator.VALID is put to the validator's cache but Optional.empty() is returned. Subsequent calls of the method return the cached ConstraintValidator.VALID which is the reason of the inconsistent behaviour.
I didn't notice this change during migration from Microanut 3 to a recent version (4.3.2) of Micronaut 4. Does it mean that @Constraint shouldn't be applied if validator of the bean comes from the factory method?
Also, I observe some inconsistency related to the validation cache. With @Constraint(validatedBy = { }) annotation preserved and the test case being modified to:
Expected Behavior
Validator should not throw the exception and behave uniformly on subsequent calls.
Actual Behaviour
Exception is thrown when
validator.validate(validBean)
is being validated:Steps To Reproduce
Included in the example application including naive workaround. Run tests to identify bug.
validator.validate()
with your valid beanvalidator.validate()
Steps 5 and 7 produce inconsistent validation behaviour.
I think that possible cause is this line:
micronaut-validation/validation/src/main/java/io/micronaut/validation/validator/constraints/DefaultConstraintValidators.java
Line 151 in 89efd63
A
ConstraintValidator.VALID
is put to the validator's cache butOptional.empty()
is returned. Subsequent calls of the method return the cachedConstraintValidator.VALID
which is the reason of the inconsistent behaviour.Environment Information
No response
Example Application
https://github.com/mancze/micronaut-sandbox/tree/repro/constraint-validation-not-found
Version
4.3.2
The text was updated successfully, but these errors were encountered: