envoyproxy/envoy

grpc async client should catch proto cast exception

Open

#5,409 opened on 2018年12月24日

GitHub で見る
 (2 comments) (0 reactions) (1 assignee)C++ (5,373 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (27,997 stars)
PR merge metrics
 (平均マージ 8d) (30d で 378 merged PRs)

説明

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;
  }
}

コントリビューターガイド