DigitsValidator and EANValidator are not serializable.
------------------------------------------------------
Key: HV-71
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-71
Project: Hibernate Validator
Issue Type: Bug
Components: validators
Affects Versions: 3.1.0.GA
Reporter: benoit heinrich
Hi all,
If you try to serialize a DigitsValidator and EANValidator validator class instance, then
you get a nice:
java.io.NotSerializableException: org.hibernate.validator.DigitsValidator
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
An easy way to reproduce it is to run the following unit test:
public class ValidatorTest {
@Test(dataProvider = "getValidators")
public void testValidatorSerialization(Validator<?> validator) throws IOException
{
OutputStream os = new ByteArrayOutputStream();
new ObjectOutputStream(os).writeObject(validator);
}
@DataProvider(name = "getValidators")
public Object[][] getValidators() {
return new Object[][] {
{new AssertFalseValidator()},
{new AssertTrueValidator()},
{new CreditCardNumberValidator()},
{new DigitsValidator()},
{new EANValidator()},
{new EmailValidator()},
{new FutureValidator()},
{new LengthValidator()},
{new MaxValidator()},
{new MinValidator()},
{new NotEmptyValidator()},
{new NotNullValidator()},
{new PastValidator()},
{new PatternValidator()},
{new RangeValidator()},
{new SizeValidator()},
};
}
}
To fix it you should simply make the two classes implementing Serializable.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira