Reread ChangeData in email constructors
Email processing is often kicked off into a background thread, so it is not safe to use the non-threadsafe accessors of Change. Rework the ChangeEmail hierarchy so a new ChangeData is created in each constructor, which ensures data is reread in a background thread. This is a little slow, particularly as not all emails are sent async, but is the best way we have of guaranteeing safety. It is also a little ugly as the destination project/branch need to be passed to a super constructor, and we can't have a statement creating this new ChangeData prior to the super call, so the ChangeData needs to be explicitly created in each leaf type. Change-Id: Ibc549791e5cb2a23fbc4d7acca96589782757296
This commit is contained in:
@@ -283,7 +283,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
||||
}
|
||||
if (!toMail.isEmpty()) {
|
||||
try {
|
||||
AddReviewerSender cm = addReviewerSenderFactory.create(change);
|
||||
AddReviewerSender cm = addReviewerSenderFactory.create(change.getId());
|
||||
cm.setFrom(identifiedUser.getAccountId());
|
||||
cm.addReviewers(toMail);
|
||||
cm.send();
|
||||
|
Reference in New Issue
Block a user