Fix ArrayIndexOutOfBoundsException.

This crash happens when the server isn't able to resolve the MSN:

FATAL EXCEPTION: IdleReader 3:Inbox
Process: com.android.email, PID: 3200
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
      at com.android.email.mail.store.ImapFolder.extractImapChanges(ImapFolder.java:1641)
      at com.android.email.mail.store.ImapFolder.access$700(ImapFolder.java:77)
      at com.android.email.mail.store.ImapFolder$1.run(ImapFolder.java:294)

Change-Id: I8a8c7cf3f2949630ee9db3646e5832246d69132d
This commit is contained in:
Danny Baumann 2015-06-08 15:18:48 +02:00 committed by Steve Kondik
parent 96a2b55e39
commit 0672de3149

View File

@ -1638,7 +1638,11 @@ public class ImapFolder extends Folder {
// Transform MSNs to UIDs
for (String msn : msns) {
String[] uids = searchForUids(String.format(Locale.US, "%s:%s", msn, msn));
imapIdleChanges.mMessageToFetch.add(uids[0]);
if (uids.length > 0) {
imapIdleChanges.mMessageToFetch.add(uids[0]);
} else {
throw new MessagingException("Server could not resolve MSN " + msn);
}
}
} catch (MessagingException ex) {
// Server doesn't support UID. We have to do a full sync (since