aboutsummaryrefslogtreecommitdiffstats
path: root/ddms
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2011-10-18 11:34:08 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-18 11:34:08 -0700
commit95a064732bb0cdea806ddd3167442c9e688eaf84 (patch)
treed9a3e3d8ccd258320dafa31812733b1e251aac09 /ddms
parent911a1f2914352fc0b64ec034b2ba0874a3ec11e3 (diff)
parent796b6c0491833587ba096a33bd0d34329f6213c5 (diff)
downloadsdk-95a064732bb0cdea806ddd3167442c9e688eaf84.zip
sdk-95a064732bb0cdea806ddd3167442c9e688eaf84.tar.gz
sdk-95a064732bb0cdea806ddd3167442c9e688eaf84.tar.bz2
Merge "Code cleanup: make sure FileInputStreams are closed."
Diffstat (limited to 'ddms')
-rw-r--r--ddms/app/src/com/android/ddms/Main.java14
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java23
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java13
3 files changed, 41 insertions, 9 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$
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java
index 9de1ac7..da41e70 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java
@@ -24,14 +24,14 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
public class BugReportImporter {
-
+
private final static String TAG_HEADER = "------ EVENT LOG TAGS ------";
private final static String LOG_HEADER = "------ EVENT LOG ------";
private final static String HEADER_TAG = "------";
-
+
private String[] mTags;
private String[] mLog;
-
+
public BugReportImporter(String filePath) throws FileNotFoundException {
BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(filePath)));
@@ -45,20 +45,27 @@ public class BugReportImporter {
}
}
} catch (IOException e) {
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ignore) {
+ }
+ }
}
}
-
+
public String[] getTags() {
return mTags;
}
-
+
public String[] getLog() {
return mLog;
}
private void readTags(BufferedReader reader) throws IOException {
String line;
-
+
ArrayList<String> content = new ArrayList<String>();
while ((line = reader.readLine()) != null) {
if (LOG_HEADER.equals(line)) {
@@ -82,8 +89,8 @@ public class BugReportImporter {
break;
}
}
-
+
mLog = content.toArray(new String[content.size()]);
}
-
+
}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java
index a1303f6..011bcf1 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java
@@ -47,6 +47,19 @@ public class EventLogImporter {
readTags(tagReader);
readLog(eventReader);
} catch (IOException e) {
+ } finally {
+ if (tagReader != null) {
+ try {
+ tagReader.close();
+ } catch (IOException ignore) {
+ }
+ }
+ if (eventReader != null) {
+ try {
+ eventReader.close();
+ } catch (IOException ignore) {
+ }
+ }
}
}