From 1d73d623875d9a95934a087b5fd9389f2299ce19 Mon Sep 17 00:00:00 2001 From: skykelsey Date: Wed, 22 Apr 2015 16:33:01 -0700 Subject: [PATCH] Ensure that streams are closed in ApptentiveClient. AND-69 --- .../com/apptentive/android/sdk/comm/ApptentiveClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apptentive/src/com/apptentive/android/sdk/comm/ApptentiveClient.java b/apptentive/src/com/apptentive/android/sdk/comm/ApptentiveClient.java index 68d3703e3..40343aebf 100755 --- a/apptentive/src/com/apptentive/android/sdk/comm/ApptentiveClient.java +++ b/apptentive/src/com/apptentive/android/sdk/comm/ApptentiveClient.java @@ -25,7 +25,6 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; -import org.apache.http.util.EntityUtils; import java.io.*; import java.net.HttpURLConnection; @@ -138,6 +137,7 @@ private static ApptentiveHttpResponse performHttpRequest(String oauthToken, Stri ApptentiveHttpResponse ret = new ApptentiveHttpResponse(); HttpClient httpClient = null; + InputStream is = null; try { HttpRequestBase request; httpClient = new DefaultHttpClient(); @@ -190,7 +190,7 @@ private static ApptentiveHttpResponse performHttpRequest(String oauthToken, Stri HttpEntity entity = response.getEntity(); if (entity != null) { - InputStream is = entity.getContent(); + is = entity.getContent(); if (is != null) { String contentEncoding = ret.getHeaders().get("Content-Encoding"); if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) { @@ -214,6 +214,7 @@ private static ApptentiveHttpResponse performHttpRequest(String oauthToken, Stri if (httpClient != null) { httpClient.getConnectionManager().shutdown(); } + Util.ensureClosed(is); } return ret; }