Fix unsafe use and copy data to Set<ConstraintViolation<?>>
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17534 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
8cc9e9d5fd
commit
8eeaaeb286
|
@ -2,6 +2,7 @@ package org.hibernate.cfg.beanvalidation;
|
|||
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
@ -67,15 +68,16 @@ public class BeanValidationEventListener implements
|
|||
.getValidator();
|
||||
final Class<?>[] groups = groupsPerOperation.get( operation );
|
||||
if ( groups.length > 0 ) {
|
||||
final Set<ConstraintViolation<T>> constraintViolations =
|
||||
validator.validate( object, groups );
|
||||
//FIXME CV should no longer be generics
|
||||
Object unsafeViolations = constraintViolations;
|
||||
final Set<ConstraintViolation<T>> constraintViolations = validator.validate( object, groups );
|
||||
if (constraintViolations.size() > 0 ) {
|
||||
//FIXME add Set<ConstraintViolation<?>>
|
||||
Set<ConstraintViolation<?>> propagatedViolations =
|
||||
new HashSet<ConstraintViolation<?>>( constraintViolations.size() );
|
||||
for ( ConstraintViolation<?> violation : constraintViolations) {
|
||||
propagatedViolations.add(violation);
|
||||
}
|
||||
throw new ConstraintViolationException(
|
||||
"Invalid object at " + operation.getName() + " time for groups " + toString( groups ),
|
||||
(Set<ConstraintViolation<?>>) unsafeViolations);
|
||||
propagatedViolations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue