You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Felix Knecht (JIRA)" <se...@james.apache.org> on 2011/09/07 17:00:11 UTC

[jira] [Closed] (JAMES-1207) Avoid file descriptor leaks

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

Felix Knecht closed JAMES-1207.
-------------------------------


> Avoid file descriptor leaks
> ---------------------------
>
>                 Key: JAMES-1207
>                 URL: https://issues.apache.org/jira/browse/JAMES-1207
>             Project: JAMES Server
>          Issue Type: Task
>    Affects Versions: Trunk
>         Environment: All
>            Reporter: Felix Knecht
>            Assignee: Felix Knecht
>             Fix For: 3.0-beta4
>
>
> Make sure, created streams get closed at least in a finally block to avoid file descriptor leaks. E.g. in code below it's not known if LineNumberReader closed the given created stream
>         try {
>             LineNumberReader counter;
>             if (getEncoding() != null) {
>                 counter = new LineNumberReader(new InputStreamReader(in, getEncoding()));
>             } else {
>                 counter = new LineNumberReader(new InputStreamReader(in));
>             }
>             //Read through all the data
>             char[] block = new char[4096];
>             while (counter.read(block) > -1) {
>                 //Just keep reading
>             }
>             return counter.getLineNumber();
>         } catch (IOException ioe) {
>             return -1;
>         } finally {
>             IOUtils.closeQuietly(in);
>         }

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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org