相关疑难解决方法(0)

CloseableHttpResponse.close()和httpPost.releaseConnection()之间有什么区别?

CloseableHttpResponse response = null;
try {
    // do some thing ....
    HttpPost request = new HttpPost("some url");
    response = getHttpClient().execute(request);
    // do some other thing ....
} catch(Exception e) {
    // deal with exception
} finally {
    if(response != null) {
        try {
            response.close(); // (1)
        } catch(Exception e) {}
        request.releaseConnection(); // (2)
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经提出了如上所述的http请求.

为了释放底层连接,调用(1)和(2)是否正确?两个调用之间有什么区别?

java httpclient

12
推荐指数
1
解决办法
3万
查看次数

标签 统计

httpclient ×1

java ×1