Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-14486 The exception classes in some throw statements do not accurately describe why they are thrown
  3. HDFS-14471

FSDirectory.resolveDotInodesPath() throws FileNotFoundException when the path is malformed

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Minor
    • Resolution: Not A Problem
    • None
    • None
    • None
    • None

    Description

      Dear HDFS developers, we are developing a tool to detect exception-related bugs in Java. Our prototype has spotted the following throw statement whose exception class and error message indicate different error conditions.

       

      Version: Hadoop-3.1.2

      File: HADOOP-ROOT/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java

      Line: 1646-1651

      try {
        id = Long.parseLong(inodeId);
      } catch (NumberFormatException e) {
        throw new FileNotFoundException("Invalid inode path: " +
            DFSUtil.byteArray2PathString(pathComponents));
      }

       

      FileNotFoundException means that a target file cannot be found. However, the error message indicates that the path is malformed (instead of well-formed but pointing to no file). This mismatch could be a problem. For example, the callers trying to handle other FileNotFoundException may accidentally (and incorrectly) handle the malformed path. Or, users/admins may be misled by the exception class name and wonder why the file is missing.

       

      Maybe the FileNotFoundException can wrap the NumberFormatException, so that the callers and users will have more idea of why the inode path is invalid.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ebugs-in-cloud-systems Haicheng Chen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: