Bug 1352608 - Close a cursor after we're done with it r=eoger. a=gchang
authorGrigory Kruglov <gkruglov@mozilla.com>
Fri, 31 Mar 2017 20:22:06 -0400
changeset 375952 ad01b1eb62fcf6b66c002f8cbcfe10565db056f1
parent 375951 7baf8f12a6438f633116b916887b1cd659ed4232
child 375953 0c74a611a3ec7c12c6f57ebdda6837d47536dbfe
push id11065
push userihsiao@mozilla.com
push dateTue, 18 Apr 2017 03:58:01 +0000
treeherdermozilla-aurora@105e456d811b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseoger, gchang
bugs1352608
milestone54.0a2
Bug 1352608 - Close a cursor after we're done with it r=eoger. a=gchang Removed "final" because "safeQuery" provides terrible developer ergonomics. MozReview-Commit-ID: 2F0XZnBM3Yv
mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FennecTabsRepository.java
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FennecTabsRepository.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/FennecTabsRepository.java
@@ -181,23 +181,28 @@ public class FennecTabsRepository extend
       };
 
       delegateQueue.execute(command);
     }
 
     private long getLocalClientLastModified() {
       final String localClientSelection = Clients.GUID + " IS NULL";
       final String[] localClientSelectionArgs = null;
+      Cursor cursor = null;
       try {
-        final Cursor cursor = clientsHelper.safeQuery(tabsProvider, ".fetchLocalClient()", null,
+        cursor = clientsHelper.safeQuery(tabsProvider, ".fetchLocalClient()", null,
                 localClientSelection, localClientSelectionArgs, null);
         cursor.moveToFirst();
         return RepoUtils.getLongFromCursor(cursor, Clients.LAST_MODIFIED);
       } catch (Exception e) {
         return 0;
+      } finally {
+        if (cursor != null) {
+          cursor.close();
+        }
       }
     }
 
     @Override
     public void fetch(final String[] guids,
                       final RepositorySessionFetchRecordsDelegate delegate) {
       // Bug 783692: Now that Bug 730039 has landed, we could implement this,
       // but it's not a priority since it's not used (yet).