hadoop-hdfs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Clampffer (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HDFS-10241) libhdfs++: Objects should never return mutable references to internal state
Date Thu, 31 Mar 2016 20:04:25 GMT
James Clampffer created HDFS-10241:
--------------------------------------

             Summary: 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
            Reporter: James Clampffer


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
(v6.3.4#6332)

Mime
View raw message