Bela Ban created JGRP-2289:
------------------------------
Summary: FRAG4: handle ObjectMessage whose size() method is incorrect
Key: JGRP-2289
URL:
https://issues.jboss.org/browse/JGRP-2289
Project: JGroups
Issue Type: Enhancement
Reporter: Bela Ban
Assignee: Bela Ban
Fix For: 5.0
When an ObjectMessage has a {{SizeStreamable}} object whose size() returns more bytes than
are actually written, {{FRAG4}} will block on reading of the last fragment. Example:
size() returns 27 bytes (LENGTH), but we only write 20 bytes, then {{readFully()}} (used
to read the fragments) will throw an exception (EOF, IIRC).
To fix this, {{FragmentedMessage.writeTo()}} could do the following:
* Check if DataOutput is of type ByteArrayDataOutputStream. This is almost always the case
as this is used on the bundler base class. If not -> use the current code path
* Remember the current position
* Write LENGTH bytes (27 in the example above)
* Call obj.writeTo(out)
* If the current position is *not* equal to the remembered position + LENGTH:
** Position the output stream back to the remembered position and write the correct length
ACTUAL bytes (20) as an int
Obviously, this only works for DataOutput implementations that support position(), but
with most bundlers using ByteArrayDataOutputStream, this should be the case most of the
time.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)