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
373b2ba4f1
commit
e3aced62ed
@ -48,7 +48,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];
|
||||||
|
@ -339,4 +339,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