Skip to content

Commit

Permalink
Merge pull request #9 from apptentive/close_streams
Browse files Browse the repository at this point in the history
Ensure that streams are closed in ApptentiveClient. AND-69
  • Loading branch information
skykelsey committed Apr 23, 2015
2 parents 5567c6a + 1d73d62 commit 05d74b9
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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")) {
Expand All @@ -214,6 +214,7 @@ private static ApptentiveHttpResponse performHttpRequest(String oauthToken, Stri
if (httpClient != null) {
httpClient.getConnectionManager().shutdown();
}
Util.ensureClosed(is);
}
return ret;
}
Expand Down

0 comments on commit 05d74b9

Please sign in to comment.