aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/app
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2011-10-13 18:47:02 -0700
committerRaphael <raphael@google.com>2011-10-13 18:47:02 -0700
commit796b6c0491833587ba096a33bd0d34329f6213c5 (patch)
tree714a82b04d421e61f18947d919e6f539b78596b4 /ddms/app
parent694eb6d79041e6ce66cd3830456826b6015d375a (diff)
downloadsdk-796b6c0491833587ba096a33bd0d34329f6213c5.zip
sdk-796b6c0491833587ba096a33bd0d34329f6213c5.tar.gz
sdk-796b6c0491833587ba096a33bd0d34329f6213c5.tar.bz2
Code cleanup: make sure FileInputStreams are closed.
Various places of the code construct a new FileInputStream on the fly and give it to another method. One many occasions the stream is never properly closed, which can lock files on Windows. 2 specific cases: - Properties.load() doesn't seem to close its input (when looking at the source bundled with the JRE). - The doc of InputSource (used by various XML parsers like the pull parser) indicates the caller should in general not close the stream and the parser itself should do it. Change-Id: I622b54a22f97ed2c9c8fdc56ccde331207d9d212
Diffstat (limited to 'ddms/app')
-rw-r--r--ddms/app/src/com/android/ddms/Main.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/ddms/app/src/com/android/ddms/Main.java b/ddms/app/src/com/android/ddms/Main.java
index 583feb5..6fe69c7 100644
--- a/ddms/app/src/com/android/ddms/Main.java
+++ b/ddms/app/src/com/android/ddms/Main.java
@@ -144,7 +144,19 @@ public class Main {
} else {
sourceProp = new File("source.properties"); //$NON-NLS-1$
}
- p.load(new FileInputStream(sourceProp));
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(sourceProp);
+ p.load(fis);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException ignore) {
+ }
+ }
+ }
+
sRevision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$
if (sRevision != null && sRevision.length() > 0) {
stats.ping("ddms", sRevision); //$NON-NLS-1$