tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Svetlin Zarev (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TOMEE-1933) InputStreamLeak in IO.java
Date Wed, 14 Sep 2016 05:54:24 GMT

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

Svetlin Zarev commented on TOMEE-1933:
--------------------------------------

Hi,

> this behavior is expected in several places now so not sure we can modify it now
It might not be OK to close the stream for slurp() that has URL or InputStream as an argument,
but the patch is only for the **slurp(File)** case. It internally opens the stream and it
never leaves the method, so it just a pure leak. Closing the file stream in slurp(file) should
not have any negative effect.

{code}
public static String slurp(final File file) throws IOException {
       final InputStream in = read(file);
       try {
           return slurp(read(file));
       } finally {
           try {
               in.close();
           } catch (IOException ex) {
               //no-op
           }
       }
}

 public static InputStream read(final File source) throws FileNotFoundException {
         final InputStream in = new FileInputStream(source);
         return new BufferedInputStream(in, 32768);
}
{code}

> InputStreamLeak in IO.java
> --------------------------
>
>                 Key: TOMEE-1933
>                 URL: https://issues.apache.org/jira/browse/TOMEE-1933
>             Project: TomEE
>          Issue Type: Bug
>            Reporter: Svetlin Zarev
>
> slurp() leaks the stream. Patch provided



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

Mime
View raw message