Commit 34a59135 by wutong

调整try catch代码范围

parent 8866309e
......@@ -2,18 +2,18 @@ package com.bailuntec.job;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bailuntec.domain.enumerate.CurrencyType;
import com.bailuntec.domain.pojo.AmazonAdAuth;
import com.bailuntec.domain.pojo.AmazonAdProduct;
import com.bailuntec.domain.pojo.AmazonAdReportLocationResult;
import com.bailuntec.domain.pojo.AmazonAdSuccessResult;
import com.bailuntec.domain.entity.DcBaseCompanyAccount;
import com.bailuntec.domain.entity.DcBaseFinanceAmazonAdProduct;
import com.bailuntec.domain.entity.JobAccountLog;
import com.bailuntec.domain.entity.JobPointLog;
import com.bailuntec.domain.enumerate.CurrencyType;
import com.bailuntec.domain.example.DcBaseCompanyAccountExample;
import com.bailuntec.domain.example.DcBaseFinanceAmazonAdProductExample;
import com.bailuntec.domain.example.JobAccountLogExample;
import com.bailuntec.domain.pojo.AmazonAdAuth;
import com.bailuntec.domain.pojo.AmazonAdProduct;
import com.bailuntec.domain.pojo.AmazonAdReportLocationResult;
import com.bailuntec.domain.pojo.AmazonAdSuccessResult;
import com.bailuntec.mapper.DcBaseCompanyAccountMapper;
import com.bailuntec.mapper.DcBaseFinanceAmazonAdProductMapper;
import com.bailuntec.mapper.JobAccountLogMapper;
......@@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
......@@ -175,12 +174,16 @@ public class AmazonAdProductJob extends PointJob {
.build();
response = client.newCall(request).execute();
if (response.isSuccessful()) {
GZIPInputStream gzin = new GZIPInputStream(response.body().byteStream());
InputStreamReader isr = new InputStreamReader(gzin, "utf8");
BufferedReader bufferedReader = new BufferedReader(isr);
StringBuffer sb = new StringBuffer();
String str = null;
GZIPInputStream gzin = null;
InputStreamReader isr = null;
BufferedReader bufferedReader = null;
try {
gzin = new GZIPInputStream(response.body().byteStream());
isr = new InputStreamReader(gzin, "utf8");
bufferedReader = new BufferedReader(isr);
StringBuffer sb = new StringBuffer();
String str = null;
while ((str = bufferedReader.readLine()) != null) {
sb.append(str);
}
......@@ -209,9 +212,15 @@ public class AmazonAdProductJob extends PointJob {
e.printStackTrace();
jobAccountLog.setMessage("解析Gzip格式的Report错误:" + ExceptionUtil.transform(e));
} finally {
bufferedReader.close();
isr.close();
gzin.close();
if(bufferedReader != null) {
bufferedReader.close();
}
if(isr != null) {
isr.close();
}
if(gzin != null) {
gzin.close();
}
}
/*
* 今天只能拿到昨天的广告费, 不然不完整
......
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