Simplify creation of ConstraintViolationExceptions

Description

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).

Environment

None

Activity

Show:
Gunnar Morling
February 21, 2010, 3:57 PM

A patch realizing the modification proposed with this issue. getConstraintViolations() now returns an empty set in case null was passed to the constructors.

Gunnar Morling
September 26, 2011, 11:18 PM

Must have.

Hardy Ferentschik
November 26, 2012, 10:54 PM

Can you create a pull request?

Gunnar Morling
November 26, 2012, 10:55 PM

Yes, will do tomorrow.

Assignee

Gunnar Morling

Reporter

Gunnar Morling

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

Priority

Major
Configure