From f15b348e6fb571bcf23087920ea807dc6cd8a567 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Mon, 3 Apr 2017 13:04:01 +0200 Subject: [PATCH] Fix potential resource leak --- .../main/java/net/fabiszewski/ulogger/GpxExportService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/fabiszewski/ulogger/GpxExportService.java b/app/src/main/java/net/fabiszewski/ulogger/GpxExportService.java index aa47b0b..4ec7d65 100644 --- a/app/src/main/java/net/fabiszewski/ulogger/GpxExportService.java +++ b/app/src/main/java/net/fabiszewski/ulogger/GpxExportService.java @@ -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))); @@ -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"); } /**