Skip to content

Commit

Permalink
Fix potential resource leak
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabiszewski committed Apr 3, 2017
1 parent f887711 commit f15b348
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ private void writePositions(@NonNull XmlSerializer serializer)
throws IOException, IllegalArgumentException, IllegalStateException {

Cursor cursor = db.getPositions();
serializer.startTag(null, "trkseg");

// suppress as it requires target api 19
//noinspection TryFinallyCanBeTryWithResources
try {
serializer.startTag(null, "trkseg");
while (cursor.moveToNext()) {
serializer.startTag(null, "trkpt");
serializer.attribute(null, "lat", cursor.getString(cursor.getColumnIndex(DbContract.Positions.COLUMN_LATITUDE)));
Expand All @@ -200,11 +200,10 @@ private void writePositions(@NonNull XmlSerializer serializer)
writeTag(serializer, "name", cursor.getString(cursor.getColumnIndex(DbContract.Positions._ID)));
serializer.endTag(null, "trkpt");
}
serializer.endTag(null, "trkseg");
} finally {
cursor.close();
}

serializer.endTag(null, "trkseg");
}

/**
Expand Down

0 comments on commit f15b348

Please sign in to comment.