You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Ian Clelland (JIRA)" <ji...@apache.org> on 2014/02/04 22:16:10 UTC
[jira] [Assigned] (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:all-tabpanel ]
Ian Clelland reassigned CB-4917:
--------------------------------
Assignee: Ian Clelland
> 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, Plugin File
> Affects Versions: 2.9.0
> Reporter: Peter
> Assignee: Ian Clelland
> 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)