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:
Dave Borowitz
2015-04-16 13:09:12 -07:00
parent 5f747fecea
commit b8a120b338
23 changed files with 84 additions and 60 deletions

View File

@@ -1045,7 +1045,7 @@ public class MergeOp {
}
try {
MergedSender cm = mergedSenderFactory.create(changeControl(c));
MergedSender cm = mergedSenderFactory.create(c.getId());
if (from != null) {
cm.setFrom(from.getAccountId());
}
@@ -1212,7 +1212,7 @@ public class MergeOp {
}
try {
MergeFailSender cm = mergeFailSenderFactory.create(c);
MergeFailSender cm = mergeFailSenderFactory.create(c.getId());
if (from != null) {
cm.setFrom(from.getAccountId());
}