Bug 1266162 - Don't throw during migration upon encountering a strange visits count r=grisha
authorGrigory Kruglov <gkruglov@mozilla.com>
Wed, 20 Apr 2016 12:12:53 -0700
changeset 331950 a4d77316a361dc337c167c5cad3fc943e0f6a844
parent 331949 dff5be5628175185fa736bed9bf789fb2ff42504
child 331951 4e06b79654439c156c079d58892c989faa18a227
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgrisha
bugs1266162
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1266162 - Don't throw during migration upon encountering a strange visits count r=grisha Sync is vast and could be strange, so let's allow for some weirdness in numbers and recover gracefully. MozReview-Commit-ID: 6o6SdcvmK8x
mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
--- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java
@@ -617,18 +617,18 @@ public final class BrowserDatabaseHelper
                     cursor.getColumnIndexOrThrow(History.VISITS));
         } finally {
             cursor.close();
         }
 
         final int visitsToSynthesize = knownVisits - baseNumberOfVisits;
 
         if (visitsToSynthesize < 0) {
-            throw new IllegalStateException(
-                    "History visits count (for guid=" + guid + ") was less than base number of visit: " + baseNumberOfVisits);
+            Log.w(LOGTAG, guid + " # of visits(" + knownVisits + ") less than # of hist.ext.db visits(" + baseNumberOfVisits + ")");
+            return 0;
         }
 
         return visitsToSynthesize;
     }
 
     private ContentValues[] generateSynthesizedVisits(int numberOfVisits, @NonNull String guid, @NonNull Long baseDate) {
         final ContentValues[] fakeVisits = new ContentValues[numberOfVisits];