You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-issues@hadoop.apache.org by "Devaraj K (JIRA)" <ji...@apache.org> on 2011/05/31 07:59:48 UTC

[jira] [Commented] (MAPREDUCE-2549) Potential resource leaks in HadoopServer.java, RunOnHadoopWizard.java and Environment.java

    [ 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