code: private int getNewBufferSize(int curSize, int minNewSize) {
        if (curSize <= DEFAULT_DOUBLING_SIZE)
           return Math.max(curSize << 1, minNewSize);
        else
           return Math.max(curSize + (curSize >> 2), minNewSize);
     }
docs: Gets the number of bytes to which the internal buffer should be resized.
  If not enough space, it doubles the size until the internal buffer
  reaches a configurable max size (default is 4MB), after which it begins
  growing the buffer in 25% increments.  This is intended to help prevent
  an OutOfMemoryError during a resize of a large buffer.
  
  @param curSize    the current number of bytes
  @param minNewSize the minimum number of bytes required
  @return the size to which the internal buffer should be resized