cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CB-4906) FB - Capture.java - method does not clean up stream
Date Wed, 25 Sep 2013 01:20:03 GMT
Peter created CB-4906:
-------------------------

             Summary: FB - Capture.java - method does not clean up stream
                 Key: CB-4906
                 URL: https://issues.apache.org/jira/browse/CB-4906
             Project: Apache Cordova
          Issue Type: Task
          Components: Android
    Affects Versions: 2.9.0
            Reporter: Peter
            Priority: Minor


Resolve FindBugs reported issue in *Capture.java*:

Before
{code}
FileInputStream fis = new FileInputStream(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity())
+ "/Capture.jpg");                    
OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
byte[] buffer = new byte[4096];
int len;
while ((len = fis.read(buffer)) != -1) {
    os.write(buffer, 0, len);
}
os.flush();
os.close();
fis.close();
{code}
After
{code}
FileInputStream fis = new FileInputStream(DirectoryManager.getTempDirectoryPath(this.cordova.getActivity())
+ "/Capture.jpg");
try {
    OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
    try {
        byte[] buffer = new byte[4096];
        int len;
        while ((len = fis.read(buffer)) != -1) {
            os.write(buffer, 0, len);
        }
        os.flush();
    } finally {
        os.close();
    }
} finally {
    fis.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

Mime
View raw message