Details
-
Sub-task
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Returning mutable references to internal state is always a bad idea. It's particularly bad in asynchronous code (due to unpredictable object life cycles).
Example of what should never happen in production code (from AsyncRequestBlock):
struct State { std::string header; hadoop::hdfs::OpReadBlockProto request; hadoop::hdfs::BlockOpResponseProto response; }; auto m = continuation::Pipeline<State>::Create(cancel_state_); State *s = &m->state(); s->header.insert(s->header.begin(), {0, kDataTransferVersion, Operation::kReadBlock});
I'll open another JIRA for auto vars containing ambiguous types e.g. what is the type of "m" here?