Commit e9abe3fc authored by Stephane Nicoll's avatar Stephane Nicoll

Polish "Do not expose `exception` error attribute by default"

Closes gh-8971
parent afe0c6f4
...@@ -256,7 +256,7 @@ public class WebRequestTraceFilterTests { ...@@ -256,7 +256,7 @@ public class WebRequestTraceFilterTests {
@Test @Test
public void filterHasError() { public void filterHasError() {
this.filter.setErrorAttributes(new DefaultErrorAttributes(false)); this.filter.setErrorAttributes(new DefaultErrorAttributes());
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo"); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
response.setStatus(500); response.setStatus(500);
......
...@@ -35,7 +35,7 @@ public class ErrorProperties { ...@@ -35,7 +35,7 @@ public class ErrorProperties {
private String path = "/error"; private String path = "/error";
/** /**
* Set whether to include "exception" attribute. * Set whether to include the "exception" attribute.
*/ */
private boolean includeException; private boolean includeException;
......
...@@ -44,7 +44,7 @@ import org.springframework.web.servlet.ModelAndView; ...@@ -44,7 +44,7 @@ import org.springframework.web.servlet.ModelAndView;
* <li>timestamp - The time that the errors were extracted</li> * <li>timestamp - The time that the errors were extracted</li>
* <li>status - The status code</li> * <li>status - The status code</li>
* <li>error - The error reason</li> * <li>error - The error reason</li>
* <li>exception - The class name of the root exception</li> * <li>exception - The class name of the root exception (if configured)</li>
* <li>message - The exception message</li> * <li>message - The exception message</li>
* <li>errors - Any {@link ObjectError}s from a {@link BindingResult} exception * <li>errors - Any {@link ObjectError}s from a {@link BindingResult} exception
* <li>trace - The exception stack trace</li> * <li>trace - The exception stack trace</li>
...@@ -69,12 +69,20 @@ public class DefaultErrorAttributes ...@@ -69,12 +69,20 @@ public class DefaultErrorAttributes
/** /**
* Create a new {@link DefaultErrorAttributes} instance. * Create a new {@link DefaultErrorAttributes} instance.
* @param includeException whether to include "exception" attribute * @param includeException whether to include the "exception" attribute
*/ */
public DefaultErrorAttributes(boolean includeException) { public DefaultErrorAttributes(boolean includeException) {
this.includeException = includeException; this.includeException = includeException;
} }
/**
* Create a new {@link DefaultErrorAttributes} instance that does not
* include the "exception" attribute.
*/
public DefaultErrorAttributes() {
this(false);
}
@Override @Override
public int getOrder() { public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE; return Ordered.HIGHEST_PRECEDENCE;
......
...@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
public class DefaultErrorAttributesTests { public class DefaultErrorAttributesTests {
private DefaultErrorAttributes errorAttributes = new DefaultErrorAttributes(false); private DefaultErrorAttributes errorAttributes = new DefaultErrorAttributes();
private MockHttpServletRequest request = new MockHttpServletRequest(); private MockHttpServletRequest request = new MockHttpServletRequest();
......
...@@ -153,7 +153,7 @@ content into your application; rather pick only the properties that you need. ...@@ -153,7 +153,7 @@ content into your application; rather pick only the properties that you need.
server.connection-timeout= # Time in milliseconds that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1 to indicate no (i.e. infinite) timeout. server.connection-timeout= # Time in milliseconds that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
server.display-name=application # Display name of the application. server.display-name=application # Display name of the application.
server.max-http-header-size=0 # Maximum size in bytes of the HTTP message header. server.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.error.include-exception=false # Set whether to include "exception" attribute. server.error.include-exception=false # Set whether to include the "exception" attribute.
server.error.include-stacktrace=never # When to include a "stacktrace" attribute. server.error.include-stacktrace=never # When to include a "stacktrace" attribute.
server.error.path=/error # Path of the error controller. server.error.path=/error # Path of the error controller.
server.error.whitelabel.enabled=true # Enable the default error page displayed in browsers in case of a server error. server.error.whitelabel.enabled=true # Enable the default error page displayed in browsers in case of a server error.
......
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