From bfa0aedad3a98296b36e584bf4c0541ab0886d4c Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Thu, 12 Sep 2019 15:29:00 +0100 Subject: [PATCH 1/2] fix: cancel appropriate queued files in flushOnLaunch() cancelQueuedFiles() prevents a file being sent again in a duplicate error report. This was inappropriately called in flushOnLaunch() before flushErrorReports() completed in a background thread, which could result in duplicate error reports. This removes the call, immediately cancels non-launch crash reports, and allows flushErrorReport() to cancel/delete each file as appropriate once the request has finished. --- .../src/main/java/com/bugsnag/android/ErrorStore.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bugsnag-android-core/src/main/java/com/bugsnag/android/ErrorStore.java b/bugsnag-android-core/src/main/java/com/bugsnag/android/ErrorStore.java index 9afb4acb02..d2ce8531ea 100644 --- a/bugsnag-android-core/src/main/java/com/bugsnag/android/ErrorStore.java +++ b/bugsnag-android-core/src/main/java/com/bugsnag/android/ErrorStore.java @@ -69,6 +69,10 @@ void flushOnLaunch() { List storedFiles = findStoredFiles(); final List crashReports = findLaunchCrashReports(storedFiles); + // cancel non-launch crash reports + storedFiles.removeAll(crashReports); + cancelQueuedFiles(storedFiles); + if (!crashReports.isEmpty()) { // Block the main thread for a 2 second interval as the app may crash very soon. @@ -102,7 +106,6 @@ public void run() { } Logger.info("Continuing with Bugsnag initialisation"); } - cancelQueuedFiles(storedFiles); // cancel all previously found files } flushAsync(); // flush any remaining errors async that weren't delivered From 4694ad80bda5bc470d5a450978093921edf6f6ca Mon Sep 17 00:00:00 2001 From: fractalwrench Date: Thu, 12 Sep 2019 15:42:31 +0100 Subject: [PATCH 2/2] docs: add changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a1ea88e74..7209457a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ### Bug fixes +* flushOnLaunch() does not cancel previous requests if they timeout, leading to potential duplicate reports + [#593](https://github.com/bugsnag/bugsnag-android/pull/593) + * Alter value collected for device.freeDisk to collect usable space in internal storage, rather than total space in internal/external storage [#589](https://github.com/bugsnag/bugsnag-android/pull/589)