public ServiceMessage decode ( ByteBuf dataBuffer , ByteBuf headersBuffer ) throws MessageCodecException { ServiceMessage . Builder builder = ServiceMessage . builder ( ) ; if ( dataBuffer . isReadable ( ) ) { builder . data ( dataBuffer ) ; } if ( headersBuffer . isReadable ( ) ) { try ( ByteBufInputStream stream = new ByteBufInputStream ( headersBuffer , true ) ) { builder . headers ( headersCodec . decode ( stream ) ) ; } catch ( Throwable ex ) { ReferenceCountUtil . safestRelease ( dataBuffer ) ; // release data buf as well throw new MessageCodecException ( "Failed to decode message headers" , ex ) ; } } return builder . build ( ) ; }
Decode buffers .