Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-14172

Avoid NPE when SectionName#fromString returns null

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.0
    • Component/s: None
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      In FSImageFormatProtobuf.SectionName#fromString(), as follows:

      public static SectionName fromString(String name) {
        for (SectionName n : values) {
          if (n.name.equals(name))
            return n;
        }
        return null;
      }
      

      When the code meets an unknown section from the fsimage, the function will return null. Callers always operates the return value with a "switch" clause, like FSImageFormatProtobuf.Loader#loadInternal(), as:

      switch (SectionName.fromString(n))
      

      NPE will be thrown here.

        Attachments

        1. HADOOP-14172.000.patch
          4 kB
          Xiang Li
        2. HADOOP-14172.001.patch
          5 kB
          Xiang Li
        3. HADOOP-14172.002.patch
          19 kB
          Xiang Li
        4. HADOOP-14172.003.patch
          12 kB
          Xiang Li
        5. HADOOP-14172.004.patch
          4 kB
          Xiang Li
        6. HADOOP-14172.005.patch
          4 kB
          Xiang Li
        7. HADOOP-14172.006.patch
          4 kB
          Xiang Li

          Activity

            People

            • Assignee:
              xiangli Xiang Li
              Reporter:
              xiangli Xiang Li
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: