mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-04 12:59:30 +00:00
Issue #6974 - fix bug in ByteBufferPool implementations
If an allocation size of 0 was requested bucketFor would throw. Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
c19921e60f
commit
377d0d131e
@ -197,7 +197,7 @@ public class ArrayByteBufferPool extends AbstractByteBufferPool implements Dumpa
|
||||
|
||||
protected int bucketFor(int capacity)
|
||||
{
|
||||
return (int)Math.ceil((double)capacity / getCapacityFactor());
|
||||
return Math.max((int)Math.ceil((double)capacity / getCapacityFactor()), 1);
|
||||
}
|
||||
|
||||
protected int capacityFor(int bucket)
|
||||
|
@ -176,7 +176,7 @@ public class MappedByteBufferPool extends AbstractByteBufferPool implements Dump
|
||||
}
|
||||
if (index >= 0)
|
||||
{
|
||||
Bucket bucket = buckets.get(index);
|
||||
Bucket bucket = buckets.remove(index);
|
||||
// Null guard in case this.clear() is called concurrently.
|
||||
if (bucket != null)
|
||||
bucket.clear();
|
||||
@ -185,7 +185,7 @@ public class MappedByteBufferPool extends AbstractByteBufferPool implements Dump
|
||||
|
||||
protected int bucketFor(int capacity)
|
||||
{
|
||||
return (int)Math.ceil((double)capacity / getCapacityFactor());
|
||||
return Math.max((int)Math.ceil((double)capacity / getCapacityFactor()), 1);
|
||||
}
|
||||
|
||||
protected int capacityFor(int bucket)
|
||||
|
Loading…
x
Reference in New Issue
Block a user