ARTEMIS-3465 BufferSplitter::split shouldn't consume input buffer

This commit is contained in:
franz1981 2021-09-09 14:52:22 +02:00 committed by clebertsuconic
parent 475d349a23
commit e379b447ff
2 changed files with 7 additions and 1 deletions

View File

@ -28,7 +28,7 @@ public class BufferSplitter {
public static void split(ActiveMQBuffer buffer, int splitSize, Consumer<EncodingSupport> target) {
byte[] bytesBuffer = new byte[buffer.readableBytes()];
buffer.readBytes(bytesBuffer);
buffer.getBytes(buffer.readerIndex(), bytesBuffer);
split(bytesBuffer, splitSize, target);
}

View File

@ -33,11 +33,17 @@ public class BufferSplitterTest {
ActiveMQBuffer outputBuffer = ActiveMQBuffers.fixedBuffer(1000 * DataConstants.SIZE_INT);
final int rdx = buffer.readerIndex();
final int readableBytes = buffer.readableBytes();
BufferSplitter.split(buffer, 77, (c) -> {
Assert.assertTrue(c.getEncodeSize() <= 77);
c.encode(outputBuffer);
});
Assert.assertEquals(rdx, buffer.readerIndex());
Assert.assertEquals(readableBytes, buffer.readableBytes());
outputBuffer.resetReaderIndex();
buffer.resetReaderIndex();