-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
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.
- is related to
-
JGRP-2285 ObjectMessage: handle objects with incorrect size
- Resolved