From 21aae1dfe29d426df2545042a48236b98363ea23 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Wed, 29 Dec 2010 17:05:04 +0000 Subject: [PATCH] Removed calls to deprecated methods git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1053675 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/impl/client/AbstractHttpClient.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java index 332140519..6a30f93bd 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java @@ -68,6 +68,7 @@ import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpProcessor; import org.apache.http.protocol.HttpRequestExecutor; import org.apache.http.protocol.ImmutableHttpProcessor; +import org.apache.http.util.EntityUtils; /** * Base class for {@link HttpClient} implementations. This class acts as @@ -845,14 +846,12 @@ public abstract class AbstractHttpClient implements HttpClient { result = responseHandler.handleResponse(response); } catch (Throwable t) { HttpEntity entity = response.getEntity(); - if (entity != null) { - try { - entity.consumeContent(); - } catch (Exception t2) { - // Log this exception. The original exception is more - // important and will be thrown to the caller. - this.log.warn("Error consuming content after an exception.", t2); - } + try { + EntityUtils.consume(entity); + } catch (Exception t2) { + // Log this exception. The original exception is more + // important and will be thrown to the caller. + this.log.warn("Error consuming content after an exception.", t2); } if (t instanceof Error) { @@ -873,11 +872,7 @@ public abstract class AbstractHttpClient implements HttpClient { // Handling the response was successful. Ensure that the content has // been fully consumed. HttpEntity entity = response.getEntity(); - if (entity != null) { - // Let this exception go to the caller. - entity.consumeContent(); - } - + EntityUtils.consume(entity); return result; }