Bug 1442248 - Don't attempt to advance to the next sync stage if we've aborted. r=eoger a=jcristau
authorRichard Newman <rnewman@mozilla.com>
Fri, 06 Apr 2018 12:01:55 -0400
changeset 463195 9b49a4d349240fc547bfe75eb8c4bca5df1784db
parent 463194 9c43b5c6ee7281835568b853c4104214c1c02809
child 463196 d464bc1927f02af0fa7c4a3d5c1b38e1530f6fab
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseoger, jcristau
bugs1442248
milestone60.0
Bug 1442248 - Don't attempt to advance to the next sync stage if we've aborted. r=eoger a=jcristau
mobile/android/services/src/main/java/org/mozilla/gecko/sync/GlobalSession.java
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/GlobalSession.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/GlobalSession.java
@@ -278,16 +278,29 @@ public class GlobalSession implements Ht
   public void advance() {
     // If we have a backoff, request a backoff and don't advance to next stage.
     long existingBackoff = largestBackoffObserved.get();
     if (existingBackoff > 0) {
       this.abort(new BackoffException(), "Aborting sync because of backoff of " + existingBackoff + " milliseconds.");
       return;
     }
 
+    // Bug 1442248. The right fix for this is to figure out why we're reaching
+    // `session.advance()` in `ServerSyncStage.onSynchronizeFailed(_, _, _)` after
+    // the session has been cleaned up. It might be that we're cleaning up/aborting when
+    // we shouldn't -- e.g., line 685 of `ServerSyncStage.java` is where we should bail
+    // out if we've aborted, and that's not the case.
+    //
+    // In the absence of someone with the time and tools to figure this out, let's just
+    // bail out here.
+    if (this.stages == null) {
+      Logger.info(LOG_TAG, "Not advancing: stages cleaned up.");
+      return;
+    }
+
     this.callback.handleStageCompleted(this.currentState, this);
     Stage next = nextStage(this.currentState);
     GlobalSyncStage nextStage;
     try {
       nextStage = this.getSyncStageByName(next);
     } catch (NoSuchStageException e) {
       this.abort(e, "No such stage " + next);
       return;