|
@@ -33,7 +33,7 @@ public class BaiduApiHelper {
|
|
|
|
|
|
try (Response response = HttpClientBuilder.getClient().newCall(request.build()).execute();
|
|
|
ResponseBody body = response.body();) {
|
|
|
- String bodyStr = body.string();
|
|
|
+ String bodyStr = body != null ? body.string() : null;
|
|
|
|
|
|
if (response.isSuccessful()) {
|
|
|
BaiduSession session = new JsonHelper().parseJson(bodyStr, BaiduSession.class);
|
|
@@ -45,7 +45,7 @@ public class BaiduApiHelper {
|
|
|
log.warn("[BAIDU] url:{} response:{} body:{}", requestUrl, response.code(), bodyStr);
|
|
|
throw new FaceVerifyException("[BAIDU] 获取AccessToken失败!");
|
|
|
} catch (IOException e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ log.error("[BAIDU] url:{} {}:{}", requestUrl, e.getClass().getSimpleName(), e.getMessage());
|
|
|
throw new FaceVerifyException("[BAIDU] 获取AccessToken异常!");
|
|
|
}
|
|
|
}
|
|
@@ -252,7 +252,7 @@ public class BaiduApiHelper {
|
|
|
Request.Builder request = new Request.Builder().url(requestUrl).post(formBody);
|
|
|
try (Response response = HttpClientBuilder.getClient().newCall(request.build()).execute();
|
|
|
ResponseBody body = response.body();) {
|
|
|
- String bodyStr = body.string();
|
|
|
+ String bodyStr = body != null ? body.string() : null;
|
|
|
|
|
|
long cost = System.currentTimeMillis() - start;
|
|
|
// System.out.println("response:" + response.code() + " cost:" + cost + "ms body:" + bodyStr);
|
|
@@ -266,10 +266,10 @@ public class BaiduApiHelper {
|
|
|
|
|
|
log.warn("[BAIDU] url:{} response:{} cost:{}ms body:{}", requestUrl, response.code(), cost, bodyStr);
|
|
|
} catch (IOException e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ log.error("[BAIDU] url:{} {}:{}", requestUrl, e.getClass().getSimpleName(), e.getMessage());
|
|
|
}
|
|
|
|
|
|
- throw new FaceVerifyException("[BAIDU] 人脸接口调用异常!");
|
|
|
+ throw new FaceVerifyException("人脸接口调用异常!");
|
|
|
}
|
|
|
|
|
|
}
|