Close stream when finished
While investigating bug 8214355, I found that the mms framework code wasn't
closing a stream. This was causing a warning and much log spew.
Change-Id: I9a6670f07092fbae969857b2f255d87466e780c7
diff --git a/src/java/com/google/android/mms/pdu/PduComposer.java b/src/java/com/google/android/mms/pdu/PduComposer.java
index d426f89..bb44bab 100644
--- a/src/java/com/google/android/mms/pdu/PduComposer.java
+++ b/src/java/com/google/android/mms/pdu/PduComposer.java
@@ -985,7 +985,7 @@
arraycopy(partData, 0, partData.length);
dataLength = partData.length;
} else {
- InputStream cr;
+ InputStream cr = null;
try {
byte[] buffer = new byte[PDU_COMPOSER_BLOCK_SIZE];
cr = mResolver.openInputStream(part.getDataUri());
@@ -1001,6 +1001,13 @@
return PDU_COMPOSE_CONTENT_ERROR;
} catch (RuntimeException e) {
return PDU_COMPOSE_CONTENT_ERROR;
+ } finally {
+ if (cr != null) {
+ try {
+ cr.close();
+ } catch (IOException e) {
+ }
+ }
}
}