Directly use the ZeroCopyInputStream for grpc::GenericDeserialize.

There is no need to use CodedInputStream, wrapping a
ZeroCopyInputStream.

Suggested by: Gerben Stavenga
pull/19920/head
Soheil Hassas Yeganeh 5 years ago
parent 5bf40ae30e
commit eadd5ea110
  1. 7
      include/grpcpp/impl/codegen/proto_utils.h

@ -83,14 +83,9 @@ Status GenericDeserialize(ByteBuffer* buffer,
if (!reader.status().ok()) {
return reader.status();
}
::grpc::protobuf::io::CodedInputStream decoder(&reader);
decoder.SetTotalBytesLimit(INT_MAX, INT_MAX);
if (!msg->ParseFromCodedStream(&decoder)) {
if (!msg->ParseFromZeroCopyStream(&reader)) {
result = Status(StatusCode::INTERNAL, msg->InitializationErrorString());
}
if (!decoder.ConsumedEntireMessage()) {
result = Status(StatusCode::INTERNAL, "Did not read entire message");
}
}
buffer->Clear();
return result;

Loading…
Cancel
Save