You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Bas Bosman (JIRA)" <ji...@apache.org> on 2014/01/26 23:27:37 UTC
[jira] [Commented] (CB-4917) FB - FileUtils.java - may fail to
clean up streams
[ 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)