Skip to content

Commit

Permalink
Merge pull request grpc#15121 from yang-g/empty_string
Browse files Browse the repository at this point in the history
handle empty slice explicitly
  • Loading branch information
yang-g committed Jun 8, 2018
2 parents 6fcbee0 + 5c67fae commit ab8642d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/grpcpp/impl/codegen/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,13 @@ class CallOpClientRecvStatus {
binary_error_details =
grpc::string(iter->second.begin(), iter->second.length());
}
*recv_status_ = Status(static_cast<StatusCode>(status_code_),
grpc::string(GRPC_SLICE_START_PTR(error_message_),
GRPC_SLICE_END_PTR(error_message_)),
binary_error_details);
*recv_status_ =
Status(static_cast<StatusCode>(status_code_),
GRPC_SLICE_IS_EMPTY(error_message_)
? grpc::string()
: grpc::string(GRPC_SLICE_START_PTR(error_message_),
GRPC_SLICE_END_PTR(error_message_)),
binary_error_details);
client_context_->set_debug_error_string(
debug_error_string_ != nullptr ? debug_error_string_ : "");
g_core_codegen_interface->grpc_slice_unref(error_message_);
Expand Down
5 changes: 5 additions & 0 deletions test/cpp/end2end/end2end_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1207,10 +1207,15 @@ TEST_P(End2endTest, ExpectErrorTest) {
ResetStub();

std::vector<ErrorStatus> expected_status;
expected_status.emplace_back();
expected_status.back().set_code(13); // INTERNAL
// No Error message or details

expected_status.emplace_back();
expected_status.back().set_code(13); // INTERNAL
expected_status.back().set_error_message("text error message");
expected_status.back().set_binary_error_details("text error details");

expected_status.emplace_back();
expected_status.back().set_code(13); // INTERNAL
expected_status.back().set_error_message("text error message");
Expand Down

0 comments on commit ab8642d

Please sign in to comment.