diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java index 5966056319..ad0c061cc2 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java @@ -164,6 +164,19 @@ class DefaultErrorAttributesTests { assertThat(attributes.get("message")).isEqualTo("Test"); } + @Test + @SuppressWarnings("deprecation") + void excludeExceptionWithDeprecatedConstructor() { + RuntimeException error = new RuntimeException("Test"); + this.errorAttributes = new DefaultErrorAttributes(false); + MockServerHttpRequest request = MockServerHttpRequest.get("/test").build(); + ServerRequest serverRequest = buildServerRequest(request, error); + Map attributes = this.errorAttributes.getErrorAttributes(serverRequest, + ErrorAttributeOptions.of()); + assertThat(this.errorAttributes.getError(serverRequest)).isSameAs(error); + assertThat(attributes.get("exception")).isNull(); + } + @Test void processResponseStatusException() { RuntimeException nested = new RuntimeException("Test"); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributesTests.java index 22ac9eee84..8c29405b9e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributesTests.java @@ -231,6 +231,17 @@ class DefaultErrorAttributesTests { assertThat(attributes.get("message")).isEqualTo("Test"); } + @Test + @SuppressWarnings("deprecation") + void excludeExceptionAttributeWithDeprecatedConstructor() { + DefaultErrorAttributes errorAttributes = new DefaultErrorAttributes(false); + RuntimeException ex = new RuntimeException("Test"); + this.request.setAttribute("javax.servlet.error.exception", ex); + Map attributes = errorAttributes.getErrorAttributes(this.webRequest, + ErrorAttributeOptions.of()); + assertThat(attributes.get("exception")).isNull(); + } + @Test void withStackTraceAttribute() { RuntimeException ex = new RuntimeException("Test");