|
|
|
I have the following validation rules defined in an interface: {code} @NotNull @DecimalMax(value= "90.0") @DecimalMin(value= "-90.0") Double getLatitude(); {code} In my tests, I also pass unexpected values such as {{ Double.NAN }} or {{ Double.POSITIVE_INFINITY }} .
This triggers an exception: {noformat} javax.validation.ValidationException: HV000028: Unexpected exception during isValid call. at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:286) at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:133) at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:91) at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:83) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:547) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:487) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:451) at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:403) at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:206) {noformat} The exception is caused by the call to {{ BigDecimal.valueOf(double val) }} in {{ org.hibernate.validator.internal.constraintvalidators.bv.DecimalMaxValidatorForNumber }} , which throws an exception if val is infinite or NaN.
The issue can be reproduced using the attached project.
|
|
|
|