Fix IndexOutOfBoundsException when FixedCompositeByteBuf is constructed with an empty array.
Motivation: When FixedCompositeByteBuf was constructed with new ByteBuf[0] and IndexOutOfboundsException was thrown. Modifications: Fix constructor Result: No more exception
This commit is contained in:
parent
4ddb81f36f
commit
7d3ca7fb92
@ -49,7 +49,7 @@ final class FixedCompositeByteBuf extends AbstractReferenceCountedByteBuf {
|
|||||||
order = ByteOrder.BIG_ENDIAN;
|
order = ByteOrder.BIG_ENDIAN;
|
||||||
nioBufferCount = 1;
|
nioBufferCount = 1;
|
||||||
capacity = 0;
|
capacity = 0;
|
||||||
direct = buffers[0].isDirect();
|
direct = false;
|
||||||
} else {
|
} else {
|
||||||
ByteBuf b = buffers[0];
|
ByteBuf b = buffers[0];
|
||||||
this.buffers = new Object[buffers.length];
|
this.buffers = new Object[buffers.length];
|
||||||
|
@ -314,4 +314,10 @@ public class FixedCompositeByteBufTest {
|
|||||||
assertEquals(1, byteBuffers[2].limit());
|
assertEquals(1, byteBuffers[2].limit());
|
||||||
composite.release();
|
composite.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEmptyArray() {
|
||||||
|
ByteBuf buf = newBuffer(new ByteBuf[0]);
|
||||||
|
buf.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user