public byte [ ] serialize ( final Object obj , final int bufferSize ) { return kryoOutputPool . run ( output -> { return kryoPool . run ( kryo -> { kryo . writeClassAndObject ( output , obj ) ; output . flush ( ) ; return output . getByteArrayOutputStream ( ) . toByteArray ( ) ; } ) ; } , bufferSize ) ; }
Serializes given object to byte array using Kryo instance in pool .