提交 c06e7a54 编写于 作者: Z zentol 提交者: Chesnay Schepler

[FLINK-11134][rest] Do not log stacktrace for handled exceptions

上级 f692d372
......@@ -116,15 +116,13 @@ public abstract class AbstractHandler<T extends RestfulGateway, R extends Reques
try {
request = MAPPER.readValue("{}", untypedResponseMessageHeaders.getRequestClass());
} catch (JsonParseException | JsonMappingException je) {
log.error("Request did not conform to expected format.", je);
throw new RestHandlerException("Bad request received.", HttpResponseStatus.BAD_REQUEST, je);
throw new RestHandlerException("Bad request received. Request did not conform to expected format.", HttpResponseStatus.BAD_REQUEST, je);
}
} else {
try {
ByteBufInputStream in = new ByteBufInputStream(msgContent);
request = MAPPER.readValue(in, untypedResponseMessageHeaders.getRequestClass());
} catch (JsonParseException | JsonMappingException je) {
log.error("Failed to read request.", je);
throw new RestHandlerException(
String.format("Request did not match expected format %s.", untypedResponseMessageHeaders.getRequestClass().getSimpleName()),
HttpResponseStatus.BAD_REQUEST,
......@@ -164,6 +162,11 @@ public abstract class AbstractHandler<T extends RestfulGateway, R extends Reques
});
} catch (RestHandlerException rhe) {
inFlightRequestTracker.deregisterRequest();
if (log.isDebugEnabled()) {
log.error("Exception occurred in REST handler.", rhe);
} else {
log.error("Exception occurred in REST handler: {}", rhe.getMessage());
}
HandlerUtils.sendErrorResponse(
ctx,
httpRequest,
......
......@@ -88,7 +88,11 @@ public abstract class AbstractRestHandler<T extends RestfulGateway, R extends Re
Throwable error = ExceptionUtils.stripCompletionException(throwable);
if (error instanceof RestHandlerException) {
final RestHandlerException rhe = (RestHandlerException) error;
log.error("Exception occurred in REST handler.", rhe);
if (log.isDebugEnabled()) {
log.error("Exception occurred in REST handler.", rhe);
} else {
log.error("Exception occurred in REST handler: {}", rhe.getMessage());
}
return Tuple2.of(new ErrorResponseBody(rhe.getMessage()), rhe.getHttpResponseStatus());
} else {
log.error("Implementation error: Unhandled exception.", error);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册