move release connection before return proxy #396

master
yihua.huang 2017-03-18 11:15:36 +08:00
parent 68beff42c5
commit 221c155060
1 changed files with 4 additions and 8 deletions

View File

@ -113,19 +113,15 @@ public class HttpClientDownloader extends AbstractDownloader {
onError(request); onError(request);
return null; return null;
} finally { } finally {
if (httpResponse != null) {
//ensure the connection is released back to pool
EntityUtils.consumeQuietly(httpResponse.getEntity());
}
request.putExtra(Request.STATUS_CODE, statusCode); request.putExtra(Request.STATUS_CODE, statusCode);
if (site != null && site.getHttpProxyPool() != null && site.getHttpProxyPool().isEnable()) { if (site != null && site.getHttpProxyPool() != null && site.getHttpProxyPool().isEnable()) {
site.returnHttpProxyToPool((HttpHost) request.getExtra(Request.PROXY), (Integer) request site.returnHttpProxyToPool((HttpHost) request.getExtra(Request.PROXY), (Integer) request
.getExtra(Request.STATUS_CODE)); .getExtra(Request.STATUS_CODE));
} }
try {
if (httpResponse != null) {
//ensure the connection is released back to pool
EntityUtils.consume(httpResponse.getEntity());
}
} catch (IOException e) {
logger.warn("close response fail", e);
}
} }
} }