Permalink
Browse files

consume responses to free up connections

  • Loading branch information...
1 parent be04f9e commit 773378ca28ca9dce6e4fdc550e1937f7ba0de511 @notnoop committed Jun 25, 2011
@@ -35,6 +35,7 @@
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.util.EntityUtils;
import com.notnoop.mpns.MpnsService;
@@ -53,7 +54,7 @@ protected void push(final HttpPost request) {
public void run() {
try {
HttpResponse response = httpClient.execute(request);
- assert response != null;
+ EntityUtils.consume(response.getEntity());
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -36,6 +36,7 @@
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
+import org.apache.http.util.EntityUtils;
import com.notnoop.mpns.MpnsService;
import com.notnoop.mpns.exceptions.NetworkIOException;
@@ -51,7 +52,7 @@ public MpnsServiceImpl(HttpClient httpClient) {
protected void push(HttpPost request) {
try {
HttpResponse response = httpClient.execute(request);
- assert response != null;
+ EntityUtils.consume(response.getEntity());
} catch (ClientProtocolException e) {
throw new RuntimeException(e);
} catch (IOException e) {

0 comments on commit 773378c

Please sign in to comment.