diff options
author | Josiah Gaskin <josiahgaskin@google.com> | 2013-09-09 10:57:05 -0700 |
---|---|---|
committer | Josiah Gaskin <josiahgaskin@google.com> | 2013-09-09 12:53:12 -0700 |
commit | fba93aa6faa7e97c3b0fc1f92ae89c8d9c740e07 (patch) | |
tree | c30854e1c543029bf5a47b3d6fb3df765f44518b /ddms | |
parent | 92d25d60c48f45c71d50377a69b21f2333c23185 (diff) | |
download | swt-fba93aa6faa7e97c3b0fc1f92ae89c8d9c740e07.tar.gz |
Fix compilation in Eclipse
Eclipse complains about several resources not being closed properly.
This fixes those errors.
Change-Id: Iedb29de906e731de418707f142e83e9ae10180ce
Diffstat (limited to 'ddms')
-rw-r--r-- | ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDataImporter.java | 99 | ||||
-rw-r--r-- | ddms/ddmuilib/src/main/java/com/android/ddmuilib/log/event/DisplaySync.java | 1 |
2 files changed, 53 insertions, 47 deletions
diff --git a/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDataImporter.java b/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDataImporter.java index 88db5cc..69437e5 100644 --- a/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDataImporter.java +++ b/ddms/ddmuilib/src/main/java/com/android/ddmuilib/heap/NativeHeapDataImporter.java @@ -33,7 +33,7 @@ import java.util.Scanner; import java.util.regex.Pattern; public class NativeHeapDataImporter implements IRunnableWithProgress { - private LineNumberReader mReader; + private final LineNumberReader mReader; private int mStartLineNumber; private int mEndLineNumber; @@ -118,67 +118,72 @@ public class NativeHeapDataImporter implements IRunnableWithProgress { private NativeAllocationInfo getNativeAllocation(String block) { Scanner sc = new Scanner(block); - String kw = sc.next(); - if (!NativeAllocationInfo.ALLOCATIONS_KW.equals(kw)) { - throw new InputMismatchException( - expectedKeywordErrorMessage(NativeAllocationInfo.ALLOCATIONS_KW, kw)); - } + try { + String kw = sc.next(); + if (!NativeAllocationInfo.ALLOCATIONS_KW.equals(kw)) { + throw new InputMismatchException( + expectedKeywordErrorMessage(NativeAllocationInfo.ALLOCATIONS_KW, kw)); + } - int allocations = sc.nextInt(); + int allocations = sc.nextInt(); - kw = sc.next(); - if (!NativeAllocationInfo.SIZE_KW.equals(kw)) { - throw new InputMismatchException( - expectedKeywordErrorMessage(NativeAllocationInfo.SIZE_KW, kw)); - } + kw = sc.next(); + if (!NativeAllocationInfo.SIZE_KW.equals(kw)) { + throw new InputMismatchException( + expectedKeywordErrorMessage(NativeAllocationInfo.SIZE_KW, kw)); + } - int size = sc.nextInt(); + int size = sc.nextInt(); - kw = sc.next(); - if (!NativeAllocationInfo.TOTAL_SIZE_KW.equals(kw)) { - throw new InputMismatchException( - expectedKeywordErrorMessage(NativeAllocationInfo.TOTAL_SIZE_KW, kw)); - } + kw = sc.next(); + if (!NativeAllocationInfo.TOTAL_SIZE_KW.equals(kw)) { + throw new InputMismatchException( + expectedKeywordErrorMessage(NativeAllocationInfo.TOTAL_SIZE_KW, kw)); + } - int totalSize = sc.nextInt(); - if (totalSize != size * allocations) { - throw new InputMismatchException( - genericErrorMessage("Total Size does not match size * # of allocations")); - } + int totalSize = sc.nextInt(); + if (totalSize != size * allocations) { + throw new InputMismatchException( + genericErrorMessage("Total Size does not match size * # of allocations")); + } - NativeAllocationInfo info = new NativeAllocationInfo(size, allocations); + NativeAllocationInfo info = new NativeAllocationInfo(size, allocations); - kw = sc.next(); - if (!NativeAllocationInfo.BEGIN_STACKTRACE_KW.equals(kw)) { - throw new InputMismatchException( - expectedKeywordErrorMessage(NativeAllocationInfo.BEGIN_STACKTRACE_KW, kw)); - } + kw = sc.next(); + if (!NativeAllocationInfo.BEGIN_STACKTRACE_KW.equals(kw)) { + throw new InputMismatchException( + expectedKeywordErrorMessage(NativeAllocationInfo.BEGIN_STACKTRACE_KW, kw)); + } - List<NativeStackCallInfo> stackInfo = new ArrayList<NativeStackCallInfo>(); - Pattern endTracePattern = Pattern.compile(NativeAllocationInfo.END_STACKTRACE_KW); + List<NativeStackCallInfo> stackInfo = new ArrayList<NativeStackCallInfo>(); + Pattern endTracePattern = Pattern.compile(NativeAllocationInfo.END_STACKTRACE_KW); - while (true) { - long address = sc.nextLong(16); - info.addStackCallAddress(address); - String library = sc.next(); - sc.next(); // ignore "---" - String method = scanTillSeparator(sc, "---"); + while (true) { + long address = sc.nextLong(16); + info.addStackCallAddress(address); - String filename = ""; - if (!isUnresolved(method, address)) { - filename = sc.next(); - } + String library = sc.next(); + sc.next(); // ignore "---" + String method = scanTillSeparator(sc, "---"); - stackInfo.add(new NativeStackCallInfo(address, library, method, filename)); + String filename = ""; + if (!isUnresolved(method, address)) { + filename = sc.next(); + } - if (sc.hasNext(endTracePattern)) { - break; + stackInfo.add(new NativeStackCallInfo(address, library, method, filename)); + + if (sc.hasNext(endTracePattern)) { + break; + } } - } - info.setResolvedStackCall(stackInfo); - return info; + info.setResolvedStackCall(stackInfo); + return info; + } finally { + sc.close(); + } } private String scanTillSeparator(Scanner sc, String separator) { diff --git a/ddms/ddmuilib/src/main/java/com/android/ddmuilib/log/event/DisplaySync.java b/ddms/ddmuilib/src/main/java/com/android/ddmuilib/log/event/DisplaySync.java index 6122513..afafec9d 100644 --- a/ddms/ddmuilib/src/main/java/com/android/ddmuilib/log/event/DisplaySync.java +++ b/ddms/ddmuilib/src/main/java/com/android/ddmuilib/log/event/DisplaySync.java @@ -261,6 +261,7 @@ public class DisplaySync extends SyncCommon { } else if (eventSource == 3) { sb.append("(user)"); } + scanner.close(); return sb.toString(); } |