From e0aefba5febf00d0c0f606920dd526989ed57e27 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Sun, 27 Sep 2009 20:55:22 -0700 Subject: [PATCH] Fix race condition NPE in medium tests (#2148940) Change-Id: I53a5fcb7eb4889da2cefa0fdc9092e44e57a2741 --- src/com/android/exchange/SyncManager.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java index f406b5e81..8d603c35a 100644 --- a/src/com/android/exchange/SyncManager.java +++ b/src/com/android/exchange/SyncManager.java @@ -1397,12 +1397,14 @@ public class SyncManager extends Service implements Runnable { if (mConnectivityReceiver != null) { unregisterReceiver(mConnectivityReceiver); } - ContentResolver resolver = getContentResolver(); - resolver.unregisterContentObserver(mAccountObserver); - resolver.unregisterContentObserver(mMailboxObserver); - resolver.unregisterContentObserver(mSyncedMessageObserver); - resolver.unregisterContentObserver(mMessageObserver); - + + if (INSTANCE != null) { + ContentResolver resolver = getContentResolver(); + resolver.unregisterContentObserver(mAccountObserver); + resolver.unregisterContentObserver(mMailboxObserver); + resolver.unregisterContentObserver(mSyncedMessageObserver); + resolver.unregisterContentObserver(mMessageObserver); + } // Don't leak the Intent associated with this listener if (mAccountsUpdatedListener != null) { AccountManager.get(this).removeOnAccountsUpdatedListener(mAccountsUpdatedListener);