Skip to content

Commit

Permalink
Do not use EntityUtils#consume, because Android hasn't this medhod be…
Browse files Browse the repository at this point in the history
…cause of obsolete version of Apache http
  • Loading branch information
matoushybl committed Jan 22, 2015
1 parent 02fe378 commit 381c34e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.mandrillapp.wrapper.lutung</groupId>
<artifactId>lutung</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.7-SNAPSHOT</version>
<name>lutung</name>
<description>Mandrill API Client for Java</description>
<url>https://github.com/rschreijer/lutung</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.List;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import com.microtripit.mandrillapp.lutung.logging.Logger;
import com.microtripit.mandrillapp.lutung.logging.LoggerFactory;
Expand Down Expand Up @@ -101,7 +102,7 @@ public static final <T> T execute(final RequestModel<T> requestModel,
responseInputStream.close();
}
if(response != null) {
EntityUtils.consume(response.getEntity());
consume(response.getEntity());
}
}
}
Expand All @@ -127,6 +128,18 @@ private static final ProxyData detectProxyServer(final String url) {
}
}

private static void consume(HttpEntity entity) throws IOException {
if (entity == null) {
return;
}
if (entity.isStreaming()) {
InputStream inputStream = entity.getContent();
if (inputStream != null) {
inputStream.close();
}
}
}

private static final class ProxyData {
String host;
int port;
Expand Down

0 comments on commit 381c34e

Please sign in to comment.