hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tsuyoshi OZAWA (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HADOOP-11414) Close of Reader should be enclosed in finally block in FileBasedIPList#readLines()
Date Wed, 17 Dec 2014 06:09:13 GMT

     [ https://issues.apache.org/jira/browse/HADOOP-11414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Tsuyoshi OZAWA updated HADOOP-11414:
------------------------------------
    Status: Patch Available  (was: Open)

> Close of Reader should be enclosed in finally block in FileBasedIPList#readLines()
> ----------------------------------------------------------------------------------
>
>                 Key: HADOOP-11414
>                 URL: https://issues.apache.org/jira/browse/HADOOP-11414
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Ted Yu
>            Priority: Minor
>         Attachments: HADOOP-11414.1.patch
>
>
> {code}
>           Reader fileReader = new InputStreamReader(
>               new FileInputStream(file), Charsets.UTF_8);
>           BufferedReader bufferedReader = new BufferedReader(fileReader);
>           List<String> lines = new ArrayList<String>();
>           String line = null;
>           while ((line = bufferedReader.readLine()) != null) {
>             lines.add(line);
>           }
>           bufferedReader.close();
> {code}
> Since bufferedReader.readLine() may throw IOE, so the close of bufferedReader should
be enclosed within finally block.



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

Mime
View raw message