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 .