envoyproxy/envoy

grpc async client should catch proto cast exception

Open

#5409 aperta il 24 dic 2018

Vedi su GitHub
 (2 commenti) (0 reazioni) (1 assegnatario)C++ (5373 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (27.997 star)
Metriche merge PR
 (Merge medio 8g) (378 PR mergiate in 30 g)

Descrizione

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

Guida contributor