Skip to content

Commit

Permalink
Merge pull request #293 from ACRA/issue-286
Browse files Browse the repository at this point in the history
Ensuring that if multiple senders and the first Sender fails that the others are attempted
  • Loading branch information
william-ferguson-au committed Jul 16, 2015
2 parents 55b2157 + 7d406fc commit 479e20f
Showing 1 changed file with 20 additions and 11 deletions.
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

0 comments on commit 479e20f

Please sign in to comment.