httpclient防止重复提交

This commit is contained in:
xuxueli 2017-08-26 14:02:07 +08:00
parent 837ab404b1
commit 667d486899
1 changed files with 4 additions and 2 deletions

View File

@ -30,7 +30,9 @@ public class HttpClientUtil {
byte[] responseBytes = null; byte[] responseBytes = null;
HttpPost httpPost = new HttpPost(reqURL); HttpPost httpPost = new HttpPost(reqURL);
CloseableHttpClient httpClient = HttpClients.createDefault(); //CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpClient httpClient = HttpClients.custom().disableAutomaticRetries().build(); // disable retry
try { try {
// init post // init post
/*if (params != null && !params.isEmpty()) { /*if (params != null && !params.isEmpty()) {
@ -62,7 +64,7 @@ public class HttpClientUtil {
EntityUtils.consume(entity); EntityUtils.consume(entity);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error("", e);
throw e; throw e;
} finally { } finally {
httpPost.releaseConnection(); httpPost.releaseConnection();