docs: private <T> T encodeAndTransform(
        ClientMessage message, BiFunction<ByteBuf, ByteBuf, T> transformer)
        throws MessageCodecException {
      ByteBuf dataBuffer = Unpooled.EMPTY_BUFFER;
      ByteBuf headersBuffer = Unpooled.EMPTY_BUFFER;
  
      if (message.hasData(ByteBuf.class)) {
        dataBuffer = message.data();
      } else if (message.hasData()) {
        dataBuffer = ByteBufAllocator.DEFAULT.buffer();
        try {
          dataCodec.encode(new ByteBufOutputStream(dataBuffer), message.data());
        } catch (Throwable ex) {
          ReferenceCountUtil.safestRelease(dataBuffer);
          LOGGER.error("Failed to encode data on: {}, cause: {}", message, ex);
          throw new MessageCodecException(
              "Failed to encode data on message q=" + message.qualifier(), ex);
        }
      }
  
      if (!message.headers().isEmpty()) {
        headersBuffer = ByteBufAllocator.DEFAULT.buffer();
        try {
          headersCodec.encode(new ByteBufOutputStream(headersBuffer), message.headers());
        } catch (Throwable ex) {
          ReferenceCountUtil.safestRelease(headersBuffer);
          ReferenceCountUtil.safestRelease(dataBuffer); // release data as well
          LOGGER.error("Failed to encode headers on: {}, cause: {}", message, ex);
          throw new MessageCodecException(
              "Failed to encode headers on message q=" + message.qualifier(), ex);
        }
      }
  
      return transformer.apply(dataBuffer, headersBuffer);
    }