ARTEMIS-3465 BufferSplitter::split shouldn't consume input buffer
This commit is contained in:
parent
475d349a23
commit
e379b447ff
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue