Fix infinite loop in AttachmentService
If Attachment.restoreAttachmentWithId fails in processQueue the
AttachmentService would end up in an infinite loop with the
following logs:
...
06-10 18:19:20.678 2369 17043 W AttachmentService: \
Could not restore attachment #776
06-10 18:19:20.680 2369 17043 W AttachmentService: \
Could not restore attachment #776
06-10 18:19:20.681 2369 17043 W AttachmentService: \
Could not restore attachment #776
06-10 18:19:20.690 2369 17043 W AttachmentService: \
Could not restore attachment #776
....
With this fix processQueue instead skips to the next
attachment, which probably was the original intent
of the code.
Change-Id: Iadea75387a6f2f5e4cfedf429ab2a42732f2c36c
diff --git a/provider_src/com/android/email/service/AttachmentService.java b/provider_src/com/android/email/service/AttachmentService.java
index 2067669..6321049 100644
--- a/provider_src/com/android/email/service/AttachmentService.java
+++ b/provider_src/com/android/email/service/AttachmentService.java
@@ -847,10 +847,10 @@
final Attachment attachment = Attachment.restoreAttachmentWithId(this, id);
if (attachment == null) {
LogUtils.w(LOG_TAG, "Could not restore attachment #%d", id);
- continue;
+ } else {
+ attachment.mFlags = (int) flags;
+ onChange(this, attachment);
}
- attachment.mFlags = (int) flags;
- onChange(this, attachment);
change = sAttachmentChangedQueue.poll();
}