[ 
https://issues.apache.org/jira/browse/HDFS-10241?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

James Clampffer updated HDFS-10241:
-----------------------------------
    Parent Issue: HDFS-14032  (was: HDFS-8707)

> libhdfs++: Objects should never return mutable references to internal state
> ---------------------------------------------------------------------------
>
>                 Key: HDFS-10241
>                 URL: https://issues.apache.org/jira/browse/HDFS-10241
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: hdfs-client
>            Reporter: James Clampffer
>            Priority: Major
>
> 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):
> {code}
>   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});
> {code}
> I'll open another JIRA for auto vars containing ambiguous types e.g. what is 
> the type of "m" here?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to