Bug 1003911 - Part 1: Don't try to extract null favicons from the database. r=margaret, a=sledru
authorRichard Newman <rnewman@mozilla.com>
Thu, 01 May 2014 14:19:33 -0700
changeset 192188 97392de21322
parent 192187 66518d59cdbd
child 192189 e03ba68c6044
push id3516
push userryanvm@gmail.com
push date2014-05-02 12:22 +0000
treeherdermozilla-beta@e03ba68c6044 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, sledru
bugs1003911
milestone30.0
Bug 1003911 - Part 1: Don't try to extract null favicons from the database. r=margaret, a=sledru
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -768,17 +768,17 @@ public class LocalBrowserDB implements B
     @Override
     public LoadFaviconResult getFaviconForUrl(ContentResolver cr, String faviconURL) {
         Cursor c = null;
         byte[] b = null;
 
         try {
             c = cr.query(mFaviconsUriWithProfile,
                          new String[] { Favicons.DATA },
-                         Favicons.URL + " = ?",
+                         Favicons.URL + " = ? AND " + Favicons.DATA + " IS NOT NULL",
                          new String[] { faviconURL },
                          null);
 
             if (!c.moveToFirst()) {
                 return null;
             }
 
             final int faviconIndex = c.getColumnIndexOrThrow(Favicons.DATA);
@@ -861,28 +861,31 @@ public class LocalBrowserDB implements B
     }
 
     @Override
     public byte[] getThumbnailForUrl(ContentResolver cr, String uri) {
         Cursor c = null;
         byte[] b = null;
         try {
             c = cr.query(mThumbnailsUriWithProfile,
-                         new String[]{Thumbnails.DATA},
-                         Thumbnails.URL + " = ?",
-                         new String[]{uri},
+                         new String[]{ Thumbnails.DATA },
+                         Thumbnails.URL + " = ? AND " + Thumbnails.DATA + " IS NOT NULL",
+                         new String[]{ uri },
                          null);
 
-            if (c.moveToFirst()) {
-                int thumbnailIndex = c.getColumnIndexOrThrow(Thumbnails.DATA);
-                b = c.getBlob(thumbnailIndex);
+            if (!c.moveToFirst()) {
+                return null;
             }
+
+            int thumbnailIndex = c.getColumnIndexOrThrow(Thumbnails.DATA);
+            b = c.getBlob(thumbnailIndex);
         } finally {
-            if (c != null)
+            if (c != null) {
                 c.close();
+            }
         }
 
         return b;
     }
 
     /**
      * Query for non-null thumbnails matching the provided <code>urls</code>.
      * The returned cursor will have no more than, but possibly fewer than,