diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-01-29 12:45:12 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-01-29 12:45:12 +0100 |
commit | c33824dedc91ddc92d5bf49339ff0cab7f4d6f28 (patch) | |
tree | 673926af631f2636879f9560ddd895e81b57aaa9 /src/org | |
parent | a5a3e2b3014cba2f1a7d356731fc3e3d066c6c62 (diff) | |
download | openpgp-api-c33824dedc91ddc92d5bf49339ff0cab7f4d6f28.tar.gz openpgp-api-c33824dedc91ddc92d5bf49339ff0cab7f4d6f28.tar.bz2 openpgp-api-c33824dedc91ddc92d5bf49339ff0cab7f4d6f28.zip |
Close input and output ParcelFileDescriptors properly also in error case
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/openintents/openpgp/util/OpenPgpApi.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/org/openintents/openpgp/util/OpenPgpApi.java index 9f51851..dbfb797 100644 --- a/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -291,6 +291,14 @@ public class OpenPgpApi { } } + /** + * InputStream and OutputStreams are always closed after operating on them! + * + * @param data + * @param is + * @param os + * @return + */ public Intent executeApi(Intent data, InputStream is, OutputStream os) { ParcelFileDescriptor input = null; ParcelFileDescriptor output = null; @@ -349,7 +357,13 @@ public class OpenPgpApi { Log.e(OpenPgpApi.TAG, "IOException when closing ParcelFileDescriptor!", e); } } - // TODO: close input? Maybe the client wants to still use the input stream + if (input != null) { + try { + input.close(); + } catch (IOException e) { + Log.e(OpenPgpApi.TAG, "IOException when closing ParcelFileDescriptor!", e); + } + } } } |