cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bas Bosman (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-4917) FB - FileUtils.java - may fail to clean up streams
Date Sun, 26 Jan 2014 22:27:37 GMT

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

Bas Bosman commented on CB-4917:
--------------------------------

Pull request: https://github.com/apache/cordova-plugin-file/pull/24

> 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 was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message