Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2289

FRAG4: handle ObjectMessage whose size() method is incorrect

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 5.0.3
    • 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.

            rhn-engineering-bban Bela Ban
            rhn-engineering-bban Bela Ban
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: