433692 improved buffer resizing

This commit is contained in:
Greg Wilkins 2014-04-30 11:57:50 +02:00
parent f65e40f8e7
commit 1c97fd3c42
1 changed files with 2 additions and 2 deletions

View File

@ -103,10 +103,10 @@ public abstract class BufferingResponseListener extends Listener.Adapter
int length = content.remaining();
if (length>BufferUtil.space(buffer))
{
int requiredCapacity = buffer.capacity()+length;
int requiredCapacity = buffer==null?0:buffer.capacity()+length;
if (requiredCapacity>maxLength)
response.abort(new IllegalArgumentException("Buffering capacity exceeded"));
int newCapacity = Math.min(Integer.highestOneBit(requiredCapacity) << 1, maxLength);
buffer = BufferUtil.ensureCapacity(buffer,newCapacity);
}