httpClient.getConnectionManager() is deprecated - what should be used instead?

后端 未结 1 909
温柔的废话
温柔的废话 2020-12-14 07:38

I have inherited the code

import org.apache.http.client.HttpClient;
...
HttpClient httpclient = createHttpClientOrProxy();

    try {
        HttpPost postR         


        
1条回答
  •  [愿得一人]
    2020-12-14 07:45

    Instead of creating a new instance of HttpClient, use the Builder. You would get a CloseableHttpClient.

    e.g usage:

    CloseableHttpClient httpClient = HttpClientBuilder.create().setProxy(proxy).build()
    

    Instead of using getConnectionManager().shutdown(), use the close() method instead on CloseableHttpClient.

    0 讨论(0)
提交回复
热议问题