Fix IndexOutOfBoundsException raised when numHeapArenas and numDirectArenas differ
- Fixes #1227
This commit is contained in:
parent
8fef511390
commit
baf9ecfe7b
@ -87,8 +87,10 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator {
|
|||||||
private final AtomicInteger index = new AtomicInteger();
|
private final AtomicInteger index = new AtomicInteger();
|
||||||
@Override
|
@Override
|
||||||
protected PoolThreadCache initialValue() {
|
protected PoolThreadCache initialValue() {
|
||||||
int idx = Math.abs(index.getAndIncrement() % heapArenas.length);
|
int idx = index.getAndIncrement();
|
||||||
return new PoolThreadCache(heapArenas[idx], directArenas[idx]);
|
int heapIdx = Math.abs(idx % heapArenas.length);
|
||||||
|
int directIdx = Math.abs(idx % directArenas.length);
|
||||||
|
return new PoolThreadCache(heapArenas[heapIdx], directArenas[directIdx]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user