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

Fix NullPointerException when File.listFiles() API returns null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.23.0
    • 0.23.0
    • None
    • None

    Description

      While testing Disk Fail Inplace, We encountered the NPE from this part of the code.

      File[] files = dir.listFiles();
      for (File f : files) {
      ...
      }

      This is kinda of an API issue. When a disk is bad (or name is not a directory), this API (listFiles, list) return null rather than throwing an exception. This 'for loop' throws a NPE exception. And same applies to dir.list() API.

      Fix all the places where null condition was not checked.

      Attachments

        1. HDFS-1934-1.patch
          2 kB
          Bharath Mundlapudi
        2. HDFS-1934-2.patch
          4 kB
          Bharath Mundlapudi
        3. HDFS-1934-3.patch
          4 kB
          Bharath Mundlapudi
        4. HDFS-1934-4.patch
          4 kB
          Bharath Mundlapudi
        5. HDFS-1934-5.patch
          4 kB
          Bharath Mundlapudi

        Issue Links

          Activity

            People

              bharathm Bharath Mundlapudi
              bharathm Bharath Mundlapudi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: