public static boolean addBuffersToStream ( ByteBuf [ ] buffers , OutputStream stream ) { if ( ! sZeroCopySendSupported || ! stream . getClass ( ) . equals ( sBufferList . getDeclaringClass ( ) ) ) { return false ; } try { if ( sCurrent . get ( stream ) != null ) { return false ; } for ( ByteBuf buffer : buffers ) { Object nettyBuffer = sNettyWritableBufferConstructor . newInstance ( buffer ) ; List list = ( List ) sBufferList . get ( stream ) ; list . add ( nettyBuffer ) ; buffer . retain ( ) ; sCurrent . set ( stream , nettyBuffer ) ; } return true ; } catch ( Exception e ) { LOG . warn ( "Failed to add data buffer to stream: {}." , e . getMessage ( ) ) ; return false ; } }
Add the given buffers directly to the gRPC output stream .