Skip to content

ByteBufferSerializer produces unexpected results with a duplicated ByteBuffer and a position > 0 #2602

@nastra

Description

@nastra

The below test shows an issue where a duplicated ByteBuffer with a position > 0 is returning unexpected results:


public void testDuplicatedByteBufferWithCustomPosition() throws IOException
{
    final byte[] INPUT_BYTES = new byte[] { 1, 2, 3, 4, 5 };
    String exp = MAPPER.writeValueAsString(new byte[] { 3, 4, 5 });

    ByteBuffer bbuf = ByteBuffer.wrap(INPUT_BYTES);

    bbuf.position(2);
    ByteBuffer duplicated = bbuf.duplicate();

    assertEquals(exp, MAPPER.writeValueAsString(duplicated));
}
Expected :"AwQF"
Actual   :"AQIDBAU="

I tested this on commit 6e5e2b0 with the 2.10 branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions