fix:禁用httpclient底层retry策略;
This commit is contained in:
parent
70783426b3
commit
d905e4fa68
|
@ -67,7 +67,6 @@ public class HttpUtil {
|
||||||
CloseableHttpClient httpClient = null;
|
CloseableHttpClient httpClient = null;
|
||||||
try{
|
try{
|
||||||
httpPost = new HttpPost(reqURL);
|
httpPost = new HttpPost(reqURL);
|
||||||
httpClient = HttpClients.createDefault();
|
|
||||||
if (params != null && !params.isEmpty()) {
|
if (params != null && !params.isEmpty()) {
|
||||||
List<NameValuePair> formParams = new ArrayList<NameValuePair>();
|
List<NameValuePair> formParams = new ArrayList<NameValuePair>();
|
||||||
for(Map.Entry<String,String> entry : params.entrySet()){
|
for(Map.Entry<String,String> entry : params.entrySet()){
|
||||||
|
@ -78,6 +77,9 @@ public class HttpUtil {
|
||||||
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();
|
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();
|
||||||
httpPost.setConfig(requestConfig);
|
httpPost.setConfig(requestConfig);
|
||||||
|
|
||||||
|
//httpClient = HttpClients.createDefault(); // default retry 3 times
|
||||||
|
httpClient = HttpClients.custom().disableAutomaticRetries().build();
|
||||||
|
|
||||||
HttpResponse response = httpClient.execute(httpPost);
|
HttpResponse response = httpClient.execute(httpPost);
|
||||||
HttpEntity entity = response.getEntity();
|
HttpEntity entity = response.getEntity();
|
||||||
if (response.getStatusLine().getStatusCode() == 200) {
|
if (response.getStatusLine().getStatusCode() == 200) {
|
||||||
|
|
Loading…
Reference in New Issue