]
Bela Ban commented on JGRP-2285:
--------------------------------
Added {{ObjectMessageTest.testIncorrectSize()}}: as suspected above, this issue is moot,
as the object is not preceeded with a length field.
ObjectMessage: handle objects with incorrect size
-------------------------------------------------
Key: JGRP-2285
URL:
https://issues.redhat.com/browse/JGRP-2285
Project: JGroups
Issue Type: Enhancement
Reporter: Bela Ban
Assignee: Bela Ban
Priority: Major
Fix For: 5.1
An ObjectMessage accepts objects of type SizeStreamable. When such an object has an
incorrect serializableSize() method, the following can happen:
* Say the serialized size is 1000, but serializedSize() returns 1200
* When the ObjectMessage is serialized, a length of 1200 is written, but then only 1000
bytes are serialized onto the output stream
* On the receiving side, length=1200 is read and a byte array of 1200 is created
* DataInput.readFully() reads 1000 bytes, but then reaches the eof of the stream, trying
to read an additional 200 bytes
* An exception is thrown and the reading of the message fails
If we caught the exception, things would work, however this would mask other errors in
the object serialization/deserialization code.
If the serialization code was able to mark the position of the output stream, then we
could write the *actual number of bytes written* (especially if it differs from
serializedSize()); however, DataOutput doesn't give us this option!
Investigate whether simply catching (and ignoring) the EOFException would work.