Commit 5ea85e61 authored by shangying's avatar shangying

sonar问题修改9

parent 7d5642b4
......@@ -109,8 +109,8 @@ public class AESUtil {
byte[] original = cipher.doFinal(encrypted1);
return original;
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
log.info("={}",e);
return null;
}
}
......
......@@ -16,7 +16,7 @@ public class GetBiNoAndFinanceProducts {
JSONArray financeProducts=new JSONArray();
JSONArray terms=new JSONArray();
JSONObject para1=new JSONObject();
if (productId == CommonType.PRODUCTTYPEONE.getCode() || productId==CommonType.PRODUCTTYPEFOUR.getCode() || productId==CommonType.PRODUCTID900.getCode() || productId==CommonType.PRODUCTID910.getCode() || productId == CommonType.PRODUCTTYPEONE.getCode()){
if (productId == CommonType.PRODUCTTYPEONE.getCode() || productId == CommonType.PRODUCTTYPEFOUR.getCode() || productId==CommonType.PRODUCTID900.getCode() || productId == CommonType.PRODUCTID910.getCode() || productId == CommonType.PRODUCTTYPEONE.getCode()){
if(productId == CommonType.PRODUCTID900.getCode()){
getResult.put("biNo", "9");
......@@ -56,8 +56,9 @@ public class GetBiNoAndFinanceProducts {
getResult.put("biNo", "2");
para1.put("min", listPara1.get(4).toString().trim());
para1.put("max",listPara1.get(0).toString().trim());
for(int i=3;i<=12;i=i+3){
int start=3;
int max=12;
for(int i=start;i<=max;i=i+start){
JSONObject jsonterm=new JSONObject();
jsonterm.put("term",i);
JSONArray fundInfo=new JSONArray();
......
......@@ -4,6 +4,7 @@ import cn.quantgroup.cashloanflowboss.utils.CommonConstant;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.Consts;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
......@@ -21,6 +22,7 @@ import java.util.Map;
* @author xh
* @date 2017年2月28日 下午2:43:45
*/
@Slf4j
public class HttpRequest {
/**
* 通过Post请求返回Json格式对象
......@@ -133,7 +135,9 @@ public class HttpRequest {
jsonObject.put("statusCode", resultEntity.getStatusCode());
}catch(Exception e){
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
}
// Logger.log("打印结果111:"+jsonObject);
......@@ -167,7 +171,8 @@ public class HttpRequest {
jsonObject.put("cookies", JSONArray.toJSON(resultEntity.getCookies()));
}catch(Exception e){
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
System.out.println("结果转传json失败,结果为:" + resultEntity.getResponseString());
}
return jsonObject;
......@@ -299,7 +304,9 @@ public class HttpRequest {
jsonObject.put("cookies", JSONArray.toJSON(resultEntity.getCookies()));
jsonObject.put("statusCode", resultEntity.getStatusCode());
}catch(Exception e){
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
System.out.println("结果转传json失败,结果为:"+resultEntity.getResponseString());
}
return jsonObject;
......
......@@ -180,7 +180,8 @@ public class HttpService {
response = httpService.getHttpClient().execute(httpGet,localContext);
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
}
if(Objects.isNull(response)){
log.info("当前的response对象是空:{}",response);
......@@ -196,17 +197,25 @@ public class HttpService {
}
} catch (MalformedURLException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
} catch (URISyntaxException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
}catch (IOException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
} finally {
if (response != null) {
try {
response.close();
} catch (IOException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
}
}
if(!Objects.isNull(httpGet)){
......@@ -222,7 +231,7 @@ public class HttpService {
Map<String, String> headerInfo, String filePath, String pwd,String charset) {
HttpResultEntity resultEntity=new HttpResultEntity();
String result = "";
if (null == url || url.isEmpty() || !url.startsWith("http")) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
if (null == url || url.isEmpty() || !url.startsWith(httpUrl)) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
return resultEntity;
}
......@@ -271,7 +280,9 @@ public class HttpService {
System.out.println("打印结果》》》》: " + response.getEntity());
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
}
log.info("进入doResponse方法之前: ");
......@@ -298,7 +309,7 @@ public class HttpService {
Map<String, String> headerInfo, String filePath, String pwd,String charset) {
HttpResultEntity resultEntity=new HttpResultEntity();
String result = "";
if (null == url || url.isEmpty() || !url.startsWith("http")) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
if (null == url || url.isEmpty() || !url.startsWith(httpUrl)) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
return resultEntity;
}
......@@ -346,7 +357,9 @@ public class HttpService {
System.out.println("打印结果》》》》: " + response.getEntity());
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}", e);
}
......@@ -461,7 +474,7 @@ public class HttpService {
Map<String, String> headerInfo, String filePath, String pwd,String charset) {
HttpResultEntity resultEntity=new HttpResultEntity();
String result = "";
if (null == url || url.isEmpty() || !url.startsWith("http")) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
if (null == url || url.isEmpty() || !url.startsWith(httpUrl)) {// 如果urlString为null或者urlString为空,或urlString非http开头,返回src空值
return resultEntity;
}
......@@ -498,7 +511,9 @@ public class HttpService {
response = httpService.getHttpClient().execute(httpPost,localContext);
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
}
result = doResponse(response, url);
resultEntity.setResponseString(result);
......@@ -519,19 +534,29 @@ public class HttpService {
instream = new FileInputStream(new File(filePath));
trustStore.load(instream, pwd.toCharArray());
} catch (CertificateException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
} catch (KeyStoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}", e);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
} finally {
try {
if (!Objects.isNull(instream)){
......@@ -539,6 +564,8 @@ public class HttpService {
}
} catch (Exception ignore) {
log.info("异常信息e={}",ignore);
}
}
......@@ -551,11 +578,14 @@ public class HttpService {
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
} catch (KeyManagementException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}", e);
} catch (KeyStoreException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}", e);
}
return HttpClients.createDefault();
......@@ -578,11 +608,14 @@ public class HttpService {
return HttpClients.custom().setSSLSocketFactory(sslsf).build();
} catch (KeyManagementException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}", e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
} catch (KeyStoreException e) {
e.printStackTrace();
// e.printStackTrace();
log.info("异常信息e={}",e);
}
return HttpClients.createDefault();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment