Bug 1352608 - Close a cursor after we're done with it r=eoger
Removed "final" because "safeQuery" provides terrible developer ergonomics.
MozReview-Commit-ID: 2F0XZnBM3Yv
--- 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).