Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensuring that if multiple senders and the first Sender fails that the others are attempted #293

Merged
merged 1 commit into from
Jul 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/main/java/org/acra/SendWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,31 @@ private void checkAndSendReports(Context context, boolean sendOnlySilentReports)
private void sendCrashReport(CrashReportData errorContent) throws ReportSenderException {
if (!ACRA.isDebuggable() || ACRA.getConfig().sendReportsInDevMode()) {
boolean sentAtLeastOnce = false;
ReportSenderException sendFailure = null;
String failedSender = null;
for (ReportSender sender : reportSenders) {
try {
ACRA.log.d(LOG_TAG, "Sending report using " + sender.getClass().getName());
sender.send(context, errorContent);
// If at least one sender worked, don't re-send the report
// later.
ACRA.log.d(LOG_TAG, "Sent report using " + sender.getClass().getName());

// If at least one sender worked, don't re-send the report later.
sentAtLeastOnce = true;
} catch (ReportSenderException e) {
if (!sentAtLeastOnce) {
throw e; // Don't log here because we aren't dealing
// with the Exception here.
} else {
ACRA.log.w(LOG_TAG,
"ReportSender of class "
+ sender.getClass().getName()
+ " failed but other senders completed their task. ACRA will not send this report again.");
}
sendFailure = e;
failedSender = sender.getClass().getName();
}
}

if (sendFailure != null) {
// We had some failure
if (!sentAtLeastOnce) {
throw sendFailure; // Don't log here because we aren't dealing with the Exception here.
} else {
ACRA.log.w(LOG_TAG,
"ReportSender of class "
+ failedSender
+ " failed but other senders completed their task. ACRA will not send this report again.");
}
}
}
Expand Down