From 4c7735b353e733473e940824a76625da46309cf1 Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Tue, 27 Aug 2013 11:01:54 +0200 Subject: [PATCH] Do not fail PostReviewers with 500 if emails cannot be sent Instead of failing with 500 Internal Server Error just write an error into the log. Change-Id: I66dd000690d09d946988d7f866e5180ee15d0b43 Signed-off-by: Edwin Kempin --- .../gerrit/server/change/PostReviewers.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java index 0441fd3f7b..5a6d441638 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/PostReviewers.java @@ -56,6 +56,8 @@ import com.google.inject.Inject; import com.google.inject.Provider; import org.eclipse.jgit.lib.Config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.text.MessageFormat; @@ -63,6 +65,9 @@ import java.util.List; import java.util.Set; public class PostReviewers implements RestModifyView { + private static final Logger log = LoggerFactory + .getLogger(PostReviewers.class); + public static final int DEFAULT_MAX_REVIEWERS_WITHOUT_CHECK = 10; public static final int DEFAULT_MAX_REVIEWERS = 20; @@ -279,12 +284,15 @@ public class PostReviewers implements RestModifyView { } } if (!added.isEmpty()) { - AddReviewerSender cm; - - cm = addReviewerSenderFactory.create(change); - cm.setFrom(currentUser.getAccountId()); - cm.addReviewers(added); - cm.send(); + try { + AddReviewerSender cm = addReviewerSenderFactory.create(change); + cm.setFrom(currentUser.getAccountId()); + cm.addReviewers(added); + cm.send(); + } catch (Exception err) { + log.error("Cannot send email to new reviewers of change " + + change.getId(), err); + } } }