Warn about ResponseEntity-ProblemDetail status mismatch

Closes gh-29378
This commit is contained in:
rstoyanchev
2022-11-01 14:10:39 +00:00
parent 921eeadff4
commit 5ef3aab3fe
2 changed files with 14 additions and 0 deletions

View File

@@ -159,6 +159,13 @@ public class ResponseEntityResultHandler extends AbstractMessageWriterResultHand
URI path = URI.create(exchange.getRequest().getPath().value());
detail.setInstance(path);
}
if (logger.isWarnEnabled() && httpEntity instanceof ResponseEntity<?> responseEntity) {
if (responseEntity.getStatusCode().value() != detail.getStatus()) {
logger.warn(actualParameter.getExecutable().toGenericString() +
" returned ResponseEntity: " + responseEntity + ", but its status" +
" doesn't match the ProblemDetail status: " + detail.getStatus());
}
}
}
if (httpEntity instanceof ResponseEntity<?> responseEntity) {

View File

@@ -197,6 +197,13 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
URI path = URI.create(inputMessage.getServletRequest().getRequestURI());
detail.setInstance(path);
}
if (logger.isWarnEnabled() && httpEntity instanceof ResponseEntity<?> responseEntity) {
if (responseEntity.getStatusCode().value() != detail.getStatus()) {
logger.warn(returnType.getExecutable().toGenericString() +
" returned ResponseEntity: " + responseEntity + ", but its status" +
" doesn't match the ProblemDetail status: " + detail.getStatus());
}
}
}
HttpHeaders outputHeaders = outputMessage.getHeaders();