配置中增加关闭连接response.close()
This commit is contained in:
@@ -134,13 +134,25 @@ 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));
|
||||
@@ -170,7 +182,13 @@ 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,7 +213,13 @@ 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,7 +255,13 @@ 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,7 +300,13 @@ 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,7 +347,13 @@ 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,7 +422,13 @@ 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,7 +465,13 @@ 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));
|
||||
@@ -449,12 +518,21 @@ 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;
|
||||
}
|
||||
@@ -503,12 +581,21 @@ 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;
|
||||
}
|
||||
|
||||
@@ -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,6 +296,10 @@ 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