回调Http状态码异常时,记录响应消息;

master
xuxueli 7 years ago
parent 7b052d7331
commit 5c0b206f33
  1. 5
      xxl-job-core/src/main/java/com/xxl/job/core/util/AdminApiUtil.java

@ -95,12 +95,13 @@ public class AdminApiUtil {
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
if (null != entity) {
String responseMsg = EntityUtils.toString(entity, "UTF-8");
if (response.getStatusLine().getStatusCode() != 200) {
EntityUtils.consume(entity);
return new ReturnT<String>(response.getStatusLine().getStatusCode(), "StatusCode Error.");
return new ReturnT<String>(response.getStatusLine().getStatusCode(),
"StatusCode(+"+ response.getStatusLine().getStatusCode() +") Error,response:" + responseMsg);
}
String responseMsg = EntityUtils.toString(entity, "UTF-8");
EntityUtils.consume(entity);
if (responseMsg!=null && responseMsg.startsWith("{")) {
ReturnT<String> result = JacksonUtil.readValue(responseMsg, ReturnT.class);

Loading…
Cancel
Save