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.