配置中增加关闭连接response.close()
This commit is contained in:
@@ -134,14 +134,26 @@ public class ConfigServiceUtil {
|
||||
if(!StringUtil.isEmpty(bean.getData())){
|
||||
list = bean.getData().getPzIdList();
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("get ids finish,cost:"+(end-start));
|
||||
return list;
|
||||
@@ -170,8 +182,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
@@ -195,8 +213,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
|
||||
}
|
||||
@@ -221,6 +245,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -228,8 +255,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
|
||||
}
|
||||
@@ -257,6 +290,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.delete();
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response != null && response.getStatus() == 200){
|
||||
@@ -264,8 +300,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
|
||||
}
|
||||
@@ -295,6 +337,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.put(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
@@ -302,8 +347,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
@@ -360,6 +411,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.post(Entity.entity(formDataMultiPart, formDataMultiPart.getMediaType()));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
@@ -368,8 +422,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
@@ -393,6 +453,9 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.post(Entity.entity(params, MediaType.APPLICATION_JSON));
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
@@ -402,8 +465,14 @@ public class ConfigServiceUtil {
|
||||
JSONObject resObject = JSONObject.fromObject(result,config);
|
||||
bean = (ToMaatResult) JSONObject.toBean(resObject,ToMaatResult.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("postGroupReuseSources end,cost:"+(end-start));
|
||||
return bean;
|
||||
@@ -449,13 +518,22 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.get();
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static String getReport(String reportUrl, SearchReport searchCondition) throws MaatConvertException, UnsupportedEncodingException{
|
||||
@@ -503,13 +581,22 @@ public class ConfigServiceUtil {
|
||||
try {
|
||||
response= header.get();
|
||||
} catch (Exception e) {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
||||
}
|
||||
if(response !=null && response.getStatus() == 200){
|
||||
result= response.readEntity(String.class);
|
||||
}else{
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -247,7 +247,7 @@ public class HttpClientUtil {
|
||||
* @param params 参数列表
|
||||
* @return 查询结果数据json
|
||||
*/
|
||||
public static String getMsg(String destUrl, Map<String, Object> params, HttpServletRequest req) {
|
||||
public static String getMsg(String destUrl, Map<String, Object> params, HttpServletRequest req) throws IOException {
|
||||
// RequestContext requestContext = new RequestContext(req);
|
||||
|
||||
// CloseableHttpResponse response = null;
|
||||
@@ -296,7 +296,11 @@ public class HttpClientUtil {
|
||||
logger.error("获取消息失败,相应内容如下: " + result);
|
||||
logger.error("获取消息失败 ", e);
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:");
|
||||
}
|
||||
}finally {
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.NtcBgpAsCfg;
|
||||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.exception.MaatConvertException;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
|
||||
Reference in New Issue
Block a user