Bug 1505720 crash [@ java.lang.NullPointerException: at org.mozilla.gecko.fxa.authenticator.AndroidFxAccount.renameAccountIfNecessary(AndroidFxAccount.java)] r=Grisha

Refreshing account (triggered by signing in) can cause a NullPointerException after quickly signing out.
This defect consists in bad sync between the signing in state and signing out state.

Differential Revision: https://phabricator.services.mozilla.com/D14269

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrei Lazar 2019-01-08 10:28:20 +00:00
Родитель cd67fe9462
Коммит 8dd6c6adf7
1 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -1077,12 +1077,15 @@ public class AndroidFxAccount {
final String resultData = bundle.getString(FxAccountProfileService.KEY_RESULT_STRING);
FxAccountUtils.pii(LOG_TAG, "Profile JSON fetch returned: " + resultData);
renameAccountIfNecessary(resultData, new Runnable() {
@Override
public void run() {
updateBundleValues(BUNDLE_KEY_PROFILE_JSON, resultData);
LocalBroadcastManager.getInstance(context).sendBroadcast(makeProfileJSONUpdatedIntent());
}
// We may get at this point due to a bad sync between states (e.g we sign in then we quickly sign out)
// Nothing else we can do but log an error.
if (!FirefoxAccounts.firefoxAccountsExist(context)) {
Logger.error(LOG_TAG, "ProfileResultReceiver: received result when no account exists!");
return;
}
renameAccountIfNecessary(resultData, () -> {
updateBundleValues(BUNDLE_KEY_PROFILE_JSON, resultData);
LocalBroadcastManager.getInstance(context).sendBroadcast(makeProfileJSONUpdatedIntent());
});
break;
case Activity.RESULT_CANCELED: