This commit is contained in:
xiangwb
2017-11-22 15:19:16 +08:00
parent 035b39c87c
commit ffb5107315
16 changed files with 87 additions and 62 deletions
@@ -1,6 +1,7 @@
package com.xwbing.util;
import com.alibaba.fastjson.JSONObject;
import com.xwbing.exception.UtilException;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.*;
import org.apache.http.client.HttpRequestRetryHandler;
@@ -130,7 +131,7 @@ public class HttpClientUtil {
post.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
} catch (UnsupportedEncodingException e) {
LOGGER.error(e.getMessage());
throw new RuntimeException("postByForm数据转换错误");
throw new UtilException("postByForm数据转换错误");
}
return getResult(post);
}
@@ -214,7 +215,7 @@ public class HttpClientUtil {
// result.setSuccess(false);
// result.setMsg(e.getMessage());
LOGGER.error(e.getMessage());
throw new RuntimeException("请求网络接口错误");
throw new UtilException("请求网络接口错误");
} finally {
poolingHttpClientConnectionManager.closeExpiredConnections();
poolingHttpClientConnectionManager.closeIdleConnections(120, TimeUnit.MILLISECONDS);