hadoop-mapreduce-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Devaraj K (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MAPREDUCE-2549) Potential resource leaks in HadoopServer.java, RunOnHadoopWizard.java and Environment.java
Date Tue, 31 May 2011 05:59:48 GMT

    [ https://issues.apache.org/jira/browse/MAPREDUCE-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041445#comment-13041445
] 

Devaraj K commented on MAPREDUCE-2549:
--------------------------------------

1. If an exception throws while writing, fos will not be closed.

{code:title=HadoopServer.java|borderStyle=solid}
  public void storeSettingsToFile(File file) throws IOException {
    FileOutputStream fos = new FileOutputStream(file);
    this.conf.writeXml(fos);
    fos.close();
  }
{code}


2. If an exception throws while writing, fos will not be closed.

{code:title=RunOnHadoopWizard.java|borderStyle=solid}
try {
      // File confFile = File.createTempFile("core-site-", ".xml",
      // confDir);
      File confFile = new File(confDir, "core-site.xml");
      FileOutputStream fos = new FileOutputStream(confFile);
      conf.writeXml(fos);
      fos.close();

    } catch (IOException ioe) {
      ioe.printStackTrace();
      return false;
    }

{code}

3. If an exception throws while reading, reader will not be closed.
{code:title=Environment.java|borderStyle=solid}
 while (true) {
      String line = in.readLine();
      if (line == null) break;
      int p = line.indexOf("=");
      if (p != -1) {
        String name = line.substring(0, p);
        String value = line.substring(p + 1);
        setProperty(name, value);
      }
    }
    in.close();

{code}


> Potential resource leaks in HadoopServer.java, RunOnHadoopWizard.java and Environment.java
> ------------------------------------------------------------------------------------------
>
>                 Key: MAPREDUCE-2549
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-2549
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>          Components: contrib/eclipse-plugin, contrib/streaming
>    Affects Versions: 0.23.0
>            Reporter: Devaraj K
>            Assignee: Devaraj K
>


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message