Skip to content

Commit 7f931bf

Browse files
committed
bug grpc-client: do not call post_recv on bad status, add missing post_recv call
- do not call PostRecv on bad status - add missing PostRecv for client streaming commit_hash:6430aeef96c7c872664aad783a53356c33b78b4b
1 parent 8927606 commit 7f931bf

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

  • grpc/include/userver/ugrpc/client

grpc/include/userver/ugrpc/client/rpc.hpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,12 @@ UnaryFuture UnaryCall<Response>::FinishAsync(Response& response) {
498498
auto& status = GetData().GetStatus();
499499
reader_->Finish(&response, &status, finish.GetTag());
500500
auto post_finish = [&response](impl::RpcData& data, const grpc::Status& status) {
501-
if constexpr (std::is_base_of_v<google::protobuf::Message, Response>) {
502-
impl::MiddlewarePipeline::PostRecvMessage(data, response);
503-
} else {
504-
(void)response; // unused by now
501+
if (status.ok()) { // response is not filled on bad status
502+
if constexpr (std::is_base_of_v<google::protobuf::Message, Response>) {
503+
impl::MiddlewarePipeline::PostRecvMessage(data, response);
504+
} else {
505+
(void)response; // unused by now
506+
}
505507
}
506508
impl::MiddlewarePipeline::PostFinish(data, status);
507509
};
@@ -586,7 +588,15 @@ Response OutputStream<Request, Response>::Finish() {
586588
impl::WritesDone(*stream_, GetData());
587589
}
588590

589-
auto post_finish = [](impl::RpcData& data, const grpc::Status& status) {
591+
auto post_finish = [this](impl::RpcData& data, const grpc::Status& status) {
592+
if (status.ok()) { // response is not filled on bad status
593+
if constexpr (std::is_base_of_v<google::protobuf::Message, Response>) {
594+
UASSERT(final_response_);
595+
impl::MiddlewarePipeline::PostRecvMessage(data, *final_response_);
596+
} else {
597+
// unused by now
598+
}
599+
}
590600
impl::MiddlewarePipeline::PostFinish(data, status);
591601
};
592602
impl::Finish(*stream_, GetData(), post_finish, true);

0 commit comments

Comments
 (0)