From a93a437ea67787d609ae417acd580e9e68fa788a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Ricau Date: Fri, 28 Aug 2015 14:01:10 -0400 Subject: [PATCH] Don't crash when heap dump fails #226 --- CHANGELOG.md | 1 + .../main/java/com/squareup/leakcanary/AndroidHeapDumper.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 502077f283..463778efcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Added excluded leaks to text report [#119](https://github.com/square/leakcanary/issues/119). * Added LeakCanary SHA to text report [#120](https://github.com/square/leakcanary/issues/120). * Renamed all resources to begin with `leak_canary_` instead of `__leak_canary`[#161](https://github.com/square/leakcanary/pull/161) +* No crash when heap dump fails [#226](https://github.com/square/leakcanary/issues/226). ### Public API changes diff --git a/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidHeapDumper.java b/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidHeapDumper.java index 7ab85f9de3..943355616a 100644 --- a/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidHeapDumper.java +++ b/leakcanary-android/src/main/java/com/squareup/leakcanary/AndroidHeapDumper.java @@ -27,7 +27,6 @@ import com.squareup.leakcanary.internal.FutureResult; import com.squareup.leakcanary.internal.LeakCanaryInternals; import java.io.File; -import java.io.IOException; import static com.squareup.leakcanary.internal.LeakCanaryInternals.isExternalStorageWritable; import static com.squareup.leakcanary.internal.LeakCanaryInternals.storageDirectory; @@ -69,7 +68,7 @@ public AndroidHeapDumper(Context context) { Debug.dumpHprofData(heapDumpFile.getAbsolutePath()); cancelToast(toast); return heapDumpFile; - } catch (IOException e) { + } catch (Exception e) { cleanup(); Log.e(TAG, "Could not perform heap dump", e); // Abort heap dump