You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Ted Yu (JIRA)" <ji...@apache.org> on 2015/01/13 22:35:34 UTC

[jira] [Created] (HADOOP-11475) Utilize try-with-resource to close StopWatch

Ted Yu created HADOOP-11475:
-------------------------------

             Summary: Utilize try-with-resource to close StopWatch
                 Key: HADOOP-11475
                 URL: https://issues.apache.org/jira/browse/HADOOP-11475
             Project: Hadoop Common
          Issue Type: Improvement
            Reporter: Ted Yu
            Priority: Minor


Currently the stop() method of StopWatch is called without using finally clause.
This can result in resource leak if there is IOE thrown.
Here is one example from Journal#journal():
{code}
    StopWatch sw = new StopWatch();
    sw.start();
    curSegment.flush(shouldFsync);
    sw.stop();
{code}
If curSegment.flush() throws IOE, sw would be left unclosed.

Propose using try-with-resource structure to close the StopWatch.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)