services-gateway-netty/src/main/java/io/scalecube/services/gateway/ServiceMessageCodec.java
/**
   * Decode buffers.
   *
   * @param dataBuffer the buffer of the data (payload)
   * @param headersBuffer the buffer of the headers
   * @return a new Service message with {@link ByteBuf} data and with parsed headers.
   * @throws MessageCodecException when decode fails
   */
Decode buffers.
@param dataBuffer the buffer of the data (payload)
@param headersBuffer the buffer of the headers
@return a new Service message with  ByteBuf data and with parsed headers.
@throws MessageCodecException when decode fails
Decode buffers . @param dataBuffer the buffer of the data ( payload ) @param headersBuffer the buffer of the headers @return a new Service message with ByteBuf data and with parsed headers . @throws MessageCodecException when decode fails
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); 
        throw new MessageCodecException("Failed to decode message headers", ex);
      }
    }
    return builder.build();
  }
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 ) ; throw new MessageCodecException ( "Failed to decode message headers" , ex ) ; } } return builder . build ( ) ; }
Decode buffers.
Decode buffers .
// release data buf as well