Skip to content

Commit 590ae57

Browse files
committed
Better closing of resources (closes #11)
1 parent 8a8833f commit 590ae57

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/io/doorbell/android/manavo/rest/RestRequest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,21 @@ private Bundle executeRequest(HttpRequest request) {
258258
Header contentEncoding = response.getFirstHeader("Content-Encoding");
259259
if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
260260
InputStream instream = entity.getContent();
261-
instream = new GZIPInputStream(instream);
261+
GZIPInputStream gzipInputStream = new GZIPInputStream(instream);
262262

263-
InputStreamReader reader = new InputStreamReader(instream);
263+
InputStreamReader reader = new InputStreamReader(gzipInputStream);
264264
BufferedReader in = new BufferedReader(reader);
265265

266266
String readed;
267267
responseData = "";
268268
while ((readed = in.readLine()) != null) {
269269
responseData += (readed);
270270
}
271+
272+
in.close();
273+
reader.close();
274+
gzipInputStream.close();
275+
instream.close();
271276
} else {
272277
responseData = EntityUtils.toString(entity);
273278
}

0 commit comments

Comments
 (0)