Given a protobuf example as below:
syntax = "proto3";
rpc TestCall(xxx)returns(Test){}
message Foo{
string a = 1;
}
message Test {
string x = 1;
string y = 2;
string z = 3;
map<string, string> map = 4;
Foo f = 5;
}
Status Interface::TestCall(ServerContext* context,const xxx* request,Test* response)
{
response->set_x("x");
response->set_y("y");
response->set_z("z");
// Leave foo.a and map blank
cout << response->x() << endl; //"z"
cout << response->y() << endl; //"z"
cout << response->z() << endl; //"z"
return Status::OK;
}
On a Mac machine, if I build up a C++ gRPC server and fill in the response, all the string variables x/y/z/a are overwritten to the last string I set("z" in this example). This issue only happens on Mac, not Windows or Linux. Also, this issue only applies to string, not int/bool/map/list.
Has anyone seen this issue before?