if (!mm.willAllocateDirect(chunkSize)) {
buffer = mm.allocate(chunkSize);
final int len;
if (!buffer.isComposite()) {
len = inputStream.read(buffer.array(),
buffer.position() + buffer.arrayOffset(),
chunkSize);
} else {
final BufferArray bufferArray = buffer.toBufferArray();
final int size = bufferArray.size();