diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-14 14:24:18 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-14 14:24:18 +1200 |
commit | d4046ab7c92eef41e0c1cce013141ecaf0c9e317 (patch) | |
tree | 51ef2117a2aba878d389dc05ea149fc00543e041 /src/org | |
parent | c21773be3d8e5626f3830e35af8a6659cae24522 (diff) | |
download | traccar-server-d4046ab7c92eef41e0c1cce013141ecaf0c9e317.tar.gz traccar-server-d4046ab7c92eef41e0c1cce013141ecaf0c9e317.tar.bz2 traccar-server-d4046ab7c92eef41e0c1cce013141ecaf0c9e317.zip |
Use try with resources
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/database/QueryBuilder.java | 7 | ||||
-rw-r--r-- | src/org/traccar/geocode/JsonReverseGeocoder.java | 5 |
2 files changed, 2 insertions, 10 deletions
diff --git a/src/org/traccar/database/QueryBuilder.java b/src/org/traccar/database/QueryBuilder.java index 85881a736..17165db82 100644 --- a/src/org/traccar/database/QueryBuilder.java +++ b/src/org/traccar/database/QueryBuilder.java @@ -292,9 +292,7 @@ public class QueryBuilder { try { - ResultSet resultSet = statement.executeQuery(); - - try { + try (ResultSet resultSet = statement.executeQuery()) { ResultSetMetaData resultMetaData = resultSet.getMetaData(); @@ -392,9 +390,6 @@ public class QueryBuilder { } result.add(object); } - - } finally { - resultSet.close(); } } finally { diff --git a/src/org/traccar/geocode/JsonReverseGeocoder.java b/src/org/traccar/geocode/JsonReverseGeocoder.java index feaaaa0ed..c43641245 100644 --- a/src/org/traccar/geocode/JsonReverseGeocoder.java +++ b/src/org/traccar/geocode/JsonReverseGeocoder.java @@ -42,15 +42,12 @@ public abstract class JsonReverseGeocoder implements ReverseGeocoder { conn.setRequestProperty("Connection", "close"); // don't keep-alive connections try { InputStreamReader streamReader = new InputStreamReader(conn.getInputStream()); - JsonReader reader = Json.createReader(streamReader); - try { + try (JsonReader reader = Json.createReader(streamReader)) { Address address = parseAddress(reader.readObject()); while (streamReader.read() > 0); // make sure we reached the end if (address != null) { return format.format(address); } - } finally { - reader.close(); } } finally { conn.disconnect(); |