Error while unserializing ImageCaptcha object in Java 1.6

Description

When the ImageCaptcha is unserializing it generates the exception:
java.io.StreamCorruptedException: unexpected end of block data
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
at com.octo.captcha.image.ImageCaptcha.readObject(ImageCaptcha.java:100)

The bug could be repeted using below code:
{{{
// assumption: captcha is an ImageCaptcha instance
ByteArrayOutputStream arrayOutput = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(arrayOutput);
out.writeObject(captcha);
out.flush();
arrayOutput.close();

ObjectInputStream in = new ObjectInputStream(new
ByteArrayInputStream(arrayOutput.toByteArray()));
Captcha captchaUnserialized = (Captcha) in.readObject();
}}}

Environment

Java1.6 and Tomcat6

Assignee

AntoineV

Reporter

Radek

Labels

None

Fix versions

Affects versions

Priority

Critical
Configure