Add null check when initializing email messaging controller visible limits.

This is to fix the NPE that would often occur during test runs. I believe the
root cause is mock accounts would be created by some email unit tests that did
not have values for all fields. Before these accounts were deleted, the main
email thread would try to access them and blow up with a NPE.
This commit is contained in:
Brett Chabot 2009-07-16 17:36:51 -07:00
parent f16f1297bd
commit 8a3b8992f9
1 changed files with 7 additions and 3 deletions

View File

@ -415,9 +415,13 @@ public class MessagingController implements Runnable {
try {
Store.StoreInfo info = Store.StoreInfo.getStoreInfo(account.getStoreUri(),
mContext);
LocalStore localStore =
(LocalStore) Store.getInstance(account.getLocalStoreUri(), mContext, null);
localStore.resetVisibleLimits(info.mVisibleLimitDefault);
// check for null to handle semi-initialized accounts created during unit tests
// store info should not be null in production scenarios
if (info != null) {
LocalStore localStore =
(LocalStore) Store.getInstance(account.getLocalStoreUri(), mContext, null);
localStore.resetVisibleLimits(info.mVisibleLimitDefault);
}
}
catch (MessagingException e) {
Log.e(Email.LOG_TAG, "Unable to reset visible limits", e);