javax.validation.ConstraintViolationException wraps a set of constraint violations, currently in the following form:
As the exception's constructors have a parameter of the same type, instantiating it is not as easy as expected:
This problem can be solved by changing the collection type to
The exception then would read as follows:
This makes the exception easier to use for producers, while maintaining simplicity for clients (since getConstraintViolations() still returns a Set<ConstraintViolation<?>>, clients don't have to do deal with the bound wildcard expression).
A patch realizing the modification proposed with this issue. getConstraintViolations() now returns an empty set in case null was passed to the constructors.
Can you create a pull request?
Yes, will do tomorrow.