Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-7090

Possible resource leaks in hadoop core code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.21.0, 0.23.0
    • 0.23.0
    • fs/s3, io
    • None
    • Reviewed
    • resource leak

    Description

      It is always a good practice to close the IO streams in a finally block..

      For example, look at the following piece of code in the Writer class of BloomMapFile

      BloomMapFile .java
          public synchronized void close() throws IOException {
            super.close();
            DataOutputStream out = fs.create(new Path(dir, BLOOM_FILE_NAME), true);
            bloomFilter.write(out);
            out.flush();
            out.close();
          }
      

      If an exception occurs during fs.create or on any other line, out.close() will not be executed..

      The following can reduce the scope of resorce leaks..

      BloomMapFile .java
          public synchronized void close() throws IOException {
            super.close();
            DataOutputStream out = null;
            try{
                out = fs.create(new Path(dir, BLOOM_FILE_NAME), true);
                bloomFilter.write(out);
                out.flush();
            }finally{
      	 IOUtils.closeStream(out);
          }
      

      Attachments

        1. HADOOP-7090.0.patch
          5 kB
          Uma Maheswara Rao G
        2. HADOOP-7090.patch
          5 kB
          Uma Maheswara Rao G

        Activity

          People

            umamaheswararao Uma Maheswara Rao G
            gokulm Gokul
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: