Hadoop Common
  1. Hadoop Common
  2. HADOOP-7090

Possible resource leaks in hadoop core code

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.21.0, 0.23.0
    • Fix Version/s: 0.23.0
    • Component/s: fs/s3, io
    • Labels:
      None
    • Hadoop Flags:
      Reviewed
    • Tags:
      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);
          }
      
      1. HADOOP-7090.0.patch
        5 kB
        Uma Maheswara Rao G
      2. HADOOP-7090.patch
        5 kB
        Uma Maheswara Rao G

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Uma Maheswara Rao G
            Reporter:
            Gokul
          • Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development