From 8cffc5b682835a2952dcd10bb2a38031f67962e5 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sat, 9 Jul 2011 15:26:30 -0400 Subject: [PATCH] Bullet proofing for user-reported exceptions in WebDAV sync: E/k9 ( 5735): java.lang.NullPointerException E/k9 ( 5735): at com.kaitenmail.mail.store.WebDavStore$WebDavMessage.setNewHeaders(WebDavStore.java:1903) E/k9 ( 5735): at com.kaitenmail.mail.store.WebDavStore$WebDavFolder.fetchEnvelope(WebDavStore.java:1655) E/k9 ( 5735): at com.kaitenmail.mail.store.WebDavStore$WebDavFolder.fetchEnvelope(WebDavStore.java:1627) E/k9 ( 5735): at com.kaitenmail.mail.store.WebDavStore$WebDavFolder.fetchEnvelope(WebDavStore.java:1627) E/k9 ( 5735): at com.kaitenmail.mail.store.WebDavStore$WebDavFolder.fetchEnvelope(WebDavStore.java:1627) E/k9 ( 5735): at com.kaitenmail.mail.store.WebDavStore$WebDavFolder.fetchEnvelope(WebDavStore.java:1627) E/k9 ( 5735): at com.kaitenmail.mail.store.WebDavStore$WebDavFolder.fetch(WebDavStore.java:1404) E/k9 ( 5735): at com.kaitenmail.controller.MessagingController.fetchUnsyncedMessages(MessagingController.java:1418) E/k9 ( 5735): at com.kaitenmail.controller.MessagingController.downloadMessages(MessagingController.java:1253) E/k9 ( 5735): at com.kaitenmail.controller.MessagingController.synchronizeMailboxSynchronous(MessagingController.java:1031) E/k9 ( 5735): at com.kaitenmail.controller.MessagingController.access$400(MessagingController.java:81) E/k9 ( 5735): at com.kaitenmail.controller.MessagingController$30.run(MessagingController.java:3768) E/k9 ( 5735): at com.kaitenmail.controller.MessagingController.run(MessagingController.java:276) E/k9 ( 5735): at java.lang.Thread.run(Thread.java:1096) --- src/com/fsck/k9/mail/store/WebDavStore.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index dfd3d9155..56828b6ba 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -1652,8 +1652,13 @@ public class WebDavStore extends Store { listener.messageStarted(messages[i].getUid(), i, count); } - wdMessage.setNewHeaders(envelopes.get(wdMessage.getUid())); - wdMessage.setFlagInternal(Flag.SEEN, envelopes.get(wdMessage.getUid()).getReadStatus()); + ParsedMessageEnvelope envelope = envelopes.get(wdMessage.getUid()); + if (envelope != null) { + wdMessage.setNewHeaders(envelope); + wdMessage.setFlagInternal(Flag.SEEN, envelope.getReadStatus()); + } else { + Log.e(K9.LOG_TAG,"Asked to get metadata for a non-existent message: "+wdMessage.getUid()); + } if (listener != null) { listener.messageFinished(messages[i], i, count);