public final ByteBuffer allocateBuffer(int size) {

        if (RECYCLE_BUFFER) {
            ByteBuffer spentBuffer = recycleChannel.poll();
            if (spentBuffer == null) {
                spentBuffer = ByteBuffer.allocateDirect(size);
            }
            spentBuffer.clear();
            return spentBuffer;
        } else {
            return ByteBuffer.allocateDirect(size);
        }
    }
public final ByteBuffer allocateBuffer(int size) {

        if (RECYCLE_BUFFER) {
            ByteBuffer spentBuffer = recycleChannel.poll();
            if (spentBuffer == null) {
                spentBuffer = ByteBuffer.allocateDirect(size);
            }
            spentBuffer.clear();
            return spentBuffer;
        } else {
            return ByteBuffer.allocateDirect(size);
        }
    }
public final ByteBuffer allocateBuffer ( int size ) { if ( RECYCLE_BUFFER ) { ByteBuffer spentBuffer = recycleChannel . poll ( ) ; if ( spentBuffer == null ) { spentBuffer = ByteBuffer . allocateDirect ( size ) ; } spentBuffer . clear ( ) ; return spentBuffer ; } else { return ByteBuffer . allocateDirect ( size ) ; } }
This gets called from the http post handler  or event bus handler.

@param size the size of the buffer that you would like.
@return
This gets called from the http post handler or event bus handler .