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

Peter updated CB-4917:
----------------------

    Issue Type: Bug  (was: Sub-task)
        Parent:     (was: CB-4909)
    
> FB - FileUtils.java - may fail to clean up streams
> --------------------------------------------------
>
>                 Key: CB-4917
>                 URL: https://issues.apache.org/jira/browse/CB-4917
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Android
>    Affects Versions: 2.9.0
>            Reporter: Peter
>            Priority: Minor
>
> Resolve FindBugs issues in *FileUtils.java*
> *In copyAction method*
> Before
> {code}
> FileInputStream istream = new FileInputStream(srcFile);
> FileOutputStream ostream = new FileOutputStream(destFile);
> FileChannel input = istream.getChannel();
> FileChannel output = ostream.getChannel();
> try {
>     input.transferTo(0, input.size(), output);
> } finally {
>     istream.close();
>     ostream.close();
>     input.close();
>     output.close();
> }
> {code}
> After
> {code}
> FileInputStream istream = new FileInputStream(srcFile);
> try {
>     FileOutputStream ostream = new FileOutputStream(destFile);
>     FileChannel input = istream.getChannel();
>     FileChannel output = ostream.getChannel();                
>     try {
>         input.transferTo(0, input.size(), output);
>     } finally {
>         ostream.close();
>         input.close();
>         output.close();
>     }
> } finally {
>     istream.close();
> }
> {code}
> *In write method*
> Before
> {code}
> ByteArrayInputStream in = new ByteArrayInputStream(rawData);
> FileOutputStream out = new FileOutputStream(filename, append);
> byte buff[] = new byte[rawData.length];
> in.read(buff, 0, buff.length);
> out.write(buff, 0, rawData.length);
> out.flush();
> out.close();
> {code}
> After
> {code}
> ByteArrayInputStream in = new ByteArrayInputStream(rawData);
> FileOutputStream out = new FileOutputStream(filename, append);
> try {
>     byte buff[] = new byte[rawData.length];
>     in.read(buff, 0, buff.length);
>     out.write(buff, 0, rawData.length);
>     out.flush();
> } finally {
>     out.close();
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to