envoyproxy/envoy

grpc async client should catch proto cast exception

Open

#5,409 创建于 2018年12月24日

在 GitHub 查看
 (2 评论) (0 反应) (1 负责人)C++ (5,373 fork)batch import
enhancementhelp wanted

仓库指标

Star
 (27,997 star)
PR 合并指标
 (平均合并 8天) (30 天内合并 378 个 PR)

描述

Title: grpc async client should catch proto cast exception

Description:

grpc async client proto cast catches no exception as follows: include\envoy\grpc\async_client.h

  void onReceiveMessageUntyped(ProtobufTypes::MessagePtr&& message) override {
    onReceiveMessage(std::unique_ptr<ResponseType>(dynamic_cast<ResponseType*>(message.release())));
  }

which may crashs the process when the received message is not standard, like 00 00 00 00 00.

And should be modified as follows:

void onReceiveMessageUntyped(ProtobufTypes::MessagePtr&& message) override {
  try {
    onReceiveMessage(std::unique_ptr<ResponseType>(dynamic_cast<ResponseType*>(message.release())));
  } catch(const std::exception& e) {
    std::cout << "wrong message received, error: " << e.what() << std::endl;
  }
}

贡献者指南