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

Closes gh-8971
This commit is contained in:
Stephane Nicoll 2017-04-27 11:15:44 +02:00
parent afe0c6f432
commit e9abe3fcca
5 changed files with 14 additions and 6 deletions

View File

@ -256,7 +256,7 @@ public class WebRequestTraceFilterTests {
@Test
public void filterHasError() {
this.filter.setErrorAttributes(new DefaultErrorAttributes(false));
this.filter.setErrorAttributes(new DefaultErrorAttributes());
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
MockHttpServletResponse response = new MockHttpServletResponse();
response.setStatus(500);

View File

@ -35,7 +35,7 @@ public class ErrorProperties {
private String path = "/error";
/**
* Set whether to include "exception" attribute.
* Set whether to include the "exception" attribute.
*/
private boolean includeException;

View File

@ -44,7 +44,7 @@ import org.springframework.web.servlet.ModelAndView;
* <li>timestamp - The time that the errors were extracted</li>
* <li>status - The status code</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>errors - Any {@link ObjectError}s from a {@link BindingResult} exception
* <li>trace - The exception stack trace</li>
@ -69,12 +69,20 @@ public class DefaultErrorAttributes
/**
* 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) {
this.includeException = includeException;
}
/**
* Create a new {@link DefaultErrorAttributes} instance that does not
* include the "exception" attribute.
*/
public DefaultErrorAttributes() {
this(false);
}
@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;

View File

@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public class DefaultErrorAttributesTests {
private DefaultErrorAttributes errorAttributes = new DefaultErrorAttributes(false);
private DefaultErrorAttributes errorAttributes = new DefaultErrorAttributes();
private MockHttpServletRequest request = new MockHttpServletRequest();

View File

@ -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.display-name=application # Display name of the application.
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.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.