deason 2 jaren geleden
bovenliggende
commit
4748d6b173

+ 5 - 5
examcloud-starters/examcloud-face-verify-starter/src/main/java/cn/com/qmth/examcloud/starters/face/verify/model/baidu/BaiduApiHelper.java

@@ -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("人脸接口调用异常!");
     }
 
 }

+ 3 - 3
examcloud-starters/examcloud-face-verify-starter/src/main/java/cn/com/qmth/examcloud/starters/face/verify/model/faceplus/FacePlusApiHelper.java

@@ -158,7 +158,7 @@ public class FacePlusApiHelper {
         long start = System.currentTimeMillis();
         try (Response response = HttpClientBuilder.getClient().newCall(request.build()).execute();
              ResponseBody body = response.body();) {
-            String bodyStr = body.string();
+            String bodyStr = body != null ? body.string() : null;
             int code = response.code();
 
             long cost = System.currentTimeMillis() - start;
@@ -180,10 +180,10 @@ public class FacePlusApiHelper {
 
             log.warn("[FACE++] url:{} response:{} cost:{}ms body:{}", requestUrl, code, cost, bodyStr);
         } catch (IOException e) {
-            log.error(e.getMessage(), e);
+            log.error("[FACE++] url:{} {}:{}", requestUrl, e.getClass().getSimpleName(), e.getMessage());
         }
 
-        throw new FaceVerifyException("[FACE++] 人脸接口调用异常!");
+        throw new FaceVerifyException("人脸接口调用异常!");
     }
 
 }