-
Bug
-
Resolution: Done
-
Major
-
1.3.0.GA
-
None
According to the Javadoc of the interface java.io.DataInput, I quote If b.length is zero, then no bytes are read which is not what classes like org.jboss.marshalling.river.BlockUnmarshaller do as we can face java.io.EOFException if we try to read an empty byte array at the end of the stream. See below a typical use case:
... protected byte[] data; ... public void readExternal(ObjectInput in) throws IOException { .. data = new byte[in.readInt()]; in.readFully(data); } public void writeExternal(ObjectOutput out) throws IOException { ... out.writeInt(data.length); out.write(data); } ...
In this use case if data.length == 0, the object will be serialized properly but if you try to de-serialize it, it will fail at in.readFully(data) with an java.io.EOFException instead of reading nothing as expected.