[#707] Fix IndexOutOfBoundsException which could accour when the buffer is consolitated in the middle of an operation
This commit is contained in:
parent
0526e1cb06
commit
4e3258973f
@ -181,7 +181,7 @@ public class DefaultCompositeByteBuf extends AbstractByteBuf implements Composit
|
|||||||
|
|
||||||
// Consolidate if the number of components will exceed the maximum by this operation.
|
// Consolidate if the number of components will exceed the maximum by this operation.
|
||||||
final int numComponents = components.size();
|
final int numComponents = components.size();
|
||||||
if (numComponents + cnt > maxNumComponents) {
|
if (numComponents + cnt >= maxNumComponents) {
|
||||||
final ByteBuf consolidated;
|
final ByteBuf consolidated;
|
||||||
if (numComponents != 0) {
|
if (numComponents != 0) {
|
||||||
final int capacity = components.get(numComponents - 1).endOffset + readableBytes;
|
final int capacity = components.get(numComponents - 1).endOffset + readableBytes;
|
||||||
@ -230,6 +230,11 @@ public class DefaultCompositeByteBuf extends AbstractByteBuf implements Composit
|
|||||||
|
|
||||||
if (b.readable()) {
|
if (b.readable()) {
|
||||||
addComponent(cIndex ++, b);
|
addComponent(cIndex ++, b);
|
||||||
|
int size = components.size();
|
||||||
|
if (cIndex > size) {
|
||||||
|
// was consolidated, so adjust index. #707
|
||||||
|
cIndex = size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
Reference in New Issue
Block a user