servicecomb-java-chassis
servicecomb-java-chassis copied to clipboard
DefaultHttpClientFilter在responseBody反序列化失败时,抛异常时的错误信息不对,误导定位
见 DefaultHttpClientFilter的异常处理
try {
result = produceProcessor.decodeResponse(responseEx.getBodyBuffer(), responseType);
Response response = Response.create(responseEx.getStatusType(), result);
if (response.isFailed()) {
LOGGER.warn("invoke operation [{}] failed, status={}, msg={}", invocation.getMicroserviceQualifiedName(),
responseEx.getStatusType().getStatusCode(), result == null ? "" : result.toString());
}
return response;
} catch (Exception e) {
LOGGER.error("failed to decode response body, exception is [{}]", e.getMessage());
String msg =
String.format("method %s, path %s, statusCode %d, reasonPhrase %s, response content-type %s is not supported",
swaggerRestOperation.getHttpMethod(),
swaggerRestOperation.getAbsolutePath(),
responseEx.getStatus(),
responseEx.getStatusType().getReasonPhrase(),
responseEx.getHeader(HttpHeaders.CONTENT_TYPE));
if (HttpStatus.isSuccess(responseEx.getStatus())) {
return Response.createConsumerFail(
new InvocationException(400, responseEx.getStatusType().getReasonPhrase(),
new CommonExceptionData(msg), e));
}
return Response.createConsumerFail(
new InvocationException(responseEx.getStatus(), responseEx.getStatusType().getReasonPhrase(),
new CommonExceptionData(msg), e));
}
如果response反序列化失败,抛的异常信息是 content-type is not supported,与记的错误日志不一致,会误导问题定位