From 7298b2dc1bf774e828f4a4fdcfed1538a6375a3d Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 13 Jan 2017 15:15:58 -0500 Subject: [PATCH] Set value of javax.servlet.error.exception_type to a Class not a String Previously, ErrorPageFilter set the value of javax.servlet.error.exception_type to be the name of the exception, (a java.lang.String). This commit changes it to be a java.lang.Class as required by the Servlet spec. Closes gh-7925 --- .../springframework/boot/web/support/ErrorPageFilter.java | 2 +- .../boot/web/support/ErrorPageFilterTests.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/web/support/ErrorPageFilter.java b/spring-boot/src/main/java/org/springframework/boot/web/support/ErrorPageFilter.java index 484bc42d08f..08c262f30d9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/support/ErrorPageFilter.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/support/ErrorPageFilter.java @@ -179,7 +179,7 @@ public class ErrorPageFilter implements Filter, ErrorPageRegistry { } setErrorAttributes(request, 500, ex.getMessage()); request.setAttribute(ERROR_EXCEPTION, ex); - request.setAttribute(ERROR_EXCEPTION_TYPE, ex.getClass().getName()); + request.setAttribute(ERROR_EXCEPTION_TYPE, ex.getClass()); response.reset(); response.sendError(500, ex.getMessage()); request.getRequestDispatcher(path).forward(request, response); diff --git a/spring-boot/src/test/java/org/springframework/boot/web/support/ErrorPageFilterTests.java b/spring-boot/src/test/java/org/springframework/boot/web/support/ErrorPageFilterTests.java index f5c03a76d82..8f0b8d33828 100644 --- a/spring-boot/src/test/java/org/springframework/boot/web/support/ErrorPageFilterTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/web/support/ErrorPageFilterTests.java @@ -262,7 +262,7 @@ public class ErrorPageFilterTests { assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE)) .isEqualTo("BAD"); assertThat(this.request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE)) - .isEqualTo(RuntimeException.class.getName()); + .isEqualTo(RuntimeException.class); assertThat(this.request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI)) .isEqualTo("/test/path"); assertThat(this.response.isCommitted()).isTrue(); @@ -319,7 +319,7 @@ public class ErrorPageFilterTests { assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE)) .isEqualTo("BAD"); assertThat(this.request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE)) - .isEqualTo(IllegalStateException.class.getName()); + .isEqualTo(IllegalStateException.class); assertThat(this.request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI)) .isEqualTo("/test/path"); assertThat(this.response.isCommitted()).isTrue(); @@ -493,7 +493,7 @@ public class ErrorPageFilterTests { assertThat(this.request.getAttribute(RequestDispatcher.ERROR_MESSAGE)) .isEqualTo("BAD"); assertThat(this.request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE)) - .isEqualTo(RuntimeException.class.getName()); + .isEqualTo(RuntimeException.class); assertThat(this.request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI)) .isEqualTo("/test/path"); assertThat(this.response.isCommitted()).isTrue();