Commit c2ec46c5 authored by Scott Frederick's avatar Scott Frederick

Polish "Fix include exception handling in DefaultErrorAttributes"

See gh-22750
parent c49605cd
......@@ -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<String, Object> 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");
......
......@@ -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<String, Object> attributes = errorAttributes.getErrorAttributes(this.webRequest,
ErrorAttributeOptions.of());
assertThat(attributes.get("exception")).isNull();
}
@Test
void withStackTraceAttribute() {
RuntimeException ex = new RuntimeException("Test");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment