Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-14032 [libhdfs++] Phase 2 improvements
  3. HDFS-10241

libhdfs++: Objects should never return mutable references to internal state

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • hdfs-client
    • 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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            James Clampffer James Clampffer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: