Uploaded image for project: 'Hadoop YARN'
  1. Hadoop YARN
  2. YARN-2484

FileSystemRMStateStore#readFile/writeFile should close FSData(In|Out)putStream in final block

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 2.6.0
    • None
    • None
    • Reviewed

    Description

      File descriptors can leak if exceptions are thrown in these methods.

       private byte[] readFile(Path inputPath, long len) throws Exception {
          FSDataInputStream fsIn = fs.open(inputPath);
          // state data will not be that "long"
          byte[] data = new byte[(int)len];
          fsIn.readFully(data);
          fsIn.close();
          return data;
        }
      
        private void writeFile(Path outputPath, byte[] data) throws Exception {
          Path tempPath =
              new Path(outputPath.getParent(), outputPath.getName() + ".tmp");
          FSDataOutputStream fsOut = null;
          // This file will be overwritten when app/attempt finishes for saving the
          // final status.
          fsOut = fs.create(tempPath, true);
          fsOut.write(data);
          fsOut.close();
          fs.rename(tempPath, outputPath);
        }
      

      Attachments

        1. YARN-2484.1.patch
          2 kB
          Tsuyoshi Ozawa
        2. YARN-2484.2.patch
          2 kB
          Tsuyoshi Ozawa

        Activity

          People

            ozawa Tsuyoshi Ozawa
            ozawa Tsuyoshi Ozawa
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: