Skip to content

Commit

Permalink
Merge pull request #12300 from nextcloud/fixCursorLeak
Browse files Browse the repository at this point in the history
Use try-with-resources for Cursor in getUploadByRemotePath
  • Loading branch information
alperozturk96 authored Dec 18, 2023
2 parents 91a689a + 8a87948 commit 69d3136
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,17 @@ public OCUpload[] getAllStoredUploads() {

public OCUpload getUploadByRemotePath(String remotePath){
OCUpload result = null;
Cursor cursor = getDB().query(
try (Cursor cursor = getDB().query(
ProviderTableMeta.CONTENT_URI_UPLOADS,
null,
ProviderTableMeta.UPLOADS_REMOTE_PATH + "=?",
new String[]{remotePath},
ProviderTableMeta.UPLOADS_REMOTE_PATH+ " ASC");
ProviderTableMeta.UPLOADS_REMOTE_PATH + " ASC")) {

if (cursor != null) {
if (cursor.moveToFirst()) {
result = createOCUploadFromCursor(cursor);
if (cursor != null) {
if (cursor.moveToFirst()) {
result = createOCUploadFromCursor(cursor);
}
}
}
Log_OC.d(TAG, "Retrieve job " + result + " for remote path " + remotePath);
Expand Down

0 comments on commit 69d3136

Please sign in to comment.