From bbdec62e37210d6abf39cb32a8a6651483d88382 Mon Sep 17 00:00:00 2001 From: luyang Date: Wed, 28 Nov 2012 00:44:25 +0100 Subject: [PATCH] Fix for StrictMode error. When the device lost connectivity, a StrictMode error could be thrown since the stream was never closed. --- src/com/fsck/k9/mail/internet/BinaryTempFileBody.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/fsck/k9/mail/internet/BinaryTempFileBody.java b/src/com/fsck/k9/mail/internet/BinaryTempFileBody.java index edfae939c..6fdbde620 100644 --- a/src/com/fsck/k9/mail/internet/BinaryTempFileBody.java +++ b/src/com/fsck/k9/mail/internet/BinaryTempFileBody.java @@ -36,9 +36,15 @@ public class BinaryTempFileBody implements Body { } public InputStream getInputStream() throws MessagingException { + InputStream is = null; + FileInputStream fis = null; try { - return new BinaryTempFileBodyInputStream(new FileInputStream(mFile)); + fis = new FileInputStream(mFile); + is = new BinaryTempFileBodyInputStream(fis); + return is; } catch (IOException ioe) { + try { if (fis != null) { fis.close(); } } catch (IOException e) { } + try { if (is != null) { is.close(); } } catch (IOException e) { } throw new MessagingException("Unable to open body", ioe); } }