envoyproxy/envoy
View on GitHubgrpc async client should catch proto cast exception
Open
#5,409 opened on Dec 24, 2018
enhancementhelp wanted
Repository metrics
- Stars
- (27,997 stars)
- PR merge metrics
- (Avg merge 8d) (378 merged PRs in 30d)
Description
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;
}
}