You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Joe Bowser (JIRA)" <ji...@apache.org> on 2015/11/16 23:35:11 UTC

[jira] [Updated] (CB-4906) FB - Capture.java - method does not clean up stream

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

Joe Bowser updated CB-4906:
---------------------------
         Labels: Android  (was: )
    Component/s:     (was: Android)

> 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: Bug
>          Components: Plugin Media Capture
>    Affects Versions: 2.9.0
>            Reporter: Peter
>            Priority: Minor
>              Labels: Android
>
> 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 was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org