Browse Source

fix:禁用httpclient底层retry策略;

xueli.xue 9 years ago
parent
commit
d905e4fa68
1 changed files with 3 additions and 1 deletions
  1. 3 1
      xxl-job-core/src/main/java/com/xxl/job/core/util/HttpUtil.java

+ 3 - 1
xxl-job-core/src/main/java/com/xxl/job/core/util/HttpUtil.java View File

67
 		CloseableHttpClient httpClient = null;
67
 		CloseableHttpClient httpClient = null;
68
 		try{
68
 		try{
69
 			httpPost = new HttpPost(reqURL);
69
 			httpPost = new HttpPost(reqURL);
70
-			httpClient = HttpClients.createDefault();
71
 			if (params != null && !params.isEmpty()) {
70
 			if (params != null && !params.isEmpty()) {
72
 				List<NameValuePair> formParams = new ArrayList<NameValuePair>();
71
 				List<NameValuePair> formParams = new ArrayList<NameValuePair>();
73
 				for(Map.Entry<String,String> entry : params.entrySet()){
72
 				for(Map.Entry<String,String> entry : params.entrySet()){
78
 			RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();
77
 			RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();
79
 			httpPost.setConfig(requestConfig);
78
 			httpPost.setConfig(requestConfig);
80
 			
79
 			
80
+			//httpClient = HttpClients.createDefault();	// default retry 3 times
81
+			httpClient = HttpClients.custom().disableAutomaticRetries().build();
82
+			
81
 			HttpResponse response = httpClient.execute(httpPost);
83
 			HttpResponse response = httpClient.execute(httpPost);
82
 			HttpEntity entity = response.getEntity();
84
 			HttpEntity entity = response.getEntity();
83
 			if (response.getStatusLine().getStatusCode() == 200) {
85
 			if (response.getStatusLine().getStatusCode() == 200) {