| This is an annoying issue: ConstraintViolationImpl might not be serializable is the constraint can concern a generic type, typically Collection. This is for instance the case of @Size. For any violation concerning the @Size constraint, be it on a collection or on a string, the ConstraintViolationImpl will not be serializable. This is due to {{ConstraintDescriptorImpl}}s and more specifically to:
@Immutable
private final List<ConstraintValidatorDescriptor<T>> matchingConstraintValidatorDescriptors;
ClassBasedValidatorDescriptor contains a reference to a Type and in the case of a Collection, it will be a sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl, which is not serializable. My vote would be to make transient all the internal fields of ConstraintDescriptorImpl. Maybe in the future, the class should be split in 2 to separate what should be in the descriptor and what is internal to HV but I think it's probably too much for a micro. Gunnar Morling what do you think? |