Nov11 / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Wrong buffer contents (bytes) when using ObjectBuffer to read object data #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Detailed Problem Description:

The issue appears when the ObjectBuffer is created with an initial capacity
that is lower than the object data to read. (If the initial capacity is
greater than the size of the object to read, the issue does not appear).

The source of the problem seems to reside in the resizeBuffer method in the
following statement:
if (preserveContents) newBuffer.put(buffer);

newBuffer.put only transfers the REMAINING bytes of buffer (the source
buffer). I think the statement should be corrected to:
if (preserveContents) {
  buffer.position(0);
  newBuffer.put(buffer);
}

What is the expected output? What do you see instead?
Without the fix above I get a wrong sequence of bytes due to copying only
remaining bytes when resizing the buffer.

What version of the Kryo are you using?
Version 1.0

Original issue reported on code.google.com by martin.r...@gmail.com on 23 Mar 2010 at 8:18

GoogleCodeExporter commented 9 years ago
Fixed in r80. Thanks!

Original comment by nathan.s...@gmail.com on 23 Mar 2010 at 11:37