private Object readResponse(Type returnType, InvokeResponse response) {
    try {
      log.trace(
          "Raw response payload: " + StandardCharsets.UTF_8.decode(response.payload()).toString());

      return streamClient.readResponse(
          returnType, new ByteBufferBackedInputStream(response.payload()));
    } catch (Throwable t) {
      if (t instanceof IOException) {
        log.warn("Could not read JSON-RPC response: ", t);
      } else {
        // This exception is raised when deserialized from the remote call, and must be
        // handled/logged in calling code; so only log at DEBUG level
        log.debug("Read an exception value from JSON-RPC response: ", t);
      }

      // wrap the raw Throwable from the JSON RPC client so that this method can be used in
      // CompletableFuture::thenApply
      throw new CompletionException(t);
    }
  }
Deserialize a JSON-RPC response from a ByteBuffer from a Lambda response payload.
json-rpc-lambda-client/src/main/java/com/amazonaws/blox/jsonrpc/JsonRpcLambdaClient.java