diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandler.java index 90f97cc9702..3021273dc39 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandler.java @@ -159,6 +159,13 @@ else if (returnValue instanceof HttpHeaders) { 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) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java index dcd2b4df64c..28f8b7ec5c0 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java @@ -197,6 +197,13 @@ else if (returnValue instanceof ProblemDetail detail) { 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();