Commit e4618cfb authored by Stephane Nicoll's avatar Stephane Nicoll

Delete ErrorProperties.IncludeStacktrace

Closes gh-21286
parent 1a2577a0
...@@ -75,13 +75,11 @@ public class ManagementErrorEndpoint { ...@@ -75,13 +75,11 @@ public class ManagementErrorEndpoint {
return options; return options;
} }
@SuppressWarnings("deprecation")
private boolean includeStackTrace(ServletWebRequest request) { private boolean includeStackTrace(ServletWebRequest request) {
switch (this.errorProperties.getIncludeStacktrace()) { switch (this.errorProperties.getIncludeStacktrace()) {
case ALWAYS: case ALWAYS:
return true; return true;
case ON_PARAM: case ON_PARAM:
case ON_TRACE_PARAM:
return getBooleanParameter(request, "trace"); return getBooleanParameter(request, "trace");
default: default:
return false; return false;
......
...@@ -61,7 +61,7 @@ class ManagementErrorEndpointTests { ...@@ -61,7 +61,7 @@ class ManagementErrorEndpointTests {
@Test @Test
void errorResponseAlwaysDetails() { void errorResponseAlwaysDetails() {
this.errorProperties.setIncludeStacktrace(ErrorProperties.IncludeStacktrace.ALWAYS); this.errorProperties.setIncludeStacktrace(ErrorProperties.IncludeAttribute.ALWAYS);
this.errorProperties.setIncludeMessage(ErrorProperties.IncludeAttribute.ALWAYS); this.errorProperties.setIncludeMessage(ErrorProperties.IncludeAttribute.ALWAYS);
this.request.addParameter("trace", "false"); this.request.addParameter("trace", "false");
this.request.addParameter("message", "false"); this.request.addParameter("message", "false");
...@@ -74,7 +74,7 @@ class ManagementErrorEndpointTests { ...@@ -74,7 +74,7 @@ class ManagementErrorEndpointTests {
@Test @Test
void errorResponseParamsAbsent() { void errorResponseParamsAbsent() {
this.errorProperties.setIncludeStacktrace(ErrorProperties.IncludeStacktrace.ON_PARAM); this.errorProperties.setIncludeStacktrace(ErrorProperties.IncludeAttribute.ON_PARAM);
this.errorProperties.setIncludeMessage(ErrorProperties.IncludeAttribute.ON_PARAM); this.errorProperties.setIncludeMessage(ErrorProperties.IncludeAttribute.ON_PARAM);
ManagementErrorEndpoint endpoint = new ManagementErrorEndpoint(this.errorAttributes, this.errorProperties); ManagementErrorEndpoint endpoint = new ManagementErrorEndpoint(this.errorAttributes, this.errorProperties);
Map<String, Object> response = endpoint.invoke(new ServletWebRequest(this.request)); Map<String, Object> response = endpoint.invoke(new ServletWebRequest(this.request));
...@@ -84,7 +84,7 @@ class ManagementErrorEndpointTests { ...@@ -84,7 +84,7 @@ class ManagementErrorEndpointTests {
@Test @Test
void errorResponseParamsTrue() { void errorResponseParamsTrue() {
this.errorProperties.setIncludeStacktrace(ErrorProperties.IncludeStacktrace.ON_PARAM); this.errorProperties.setIncludeStacktrace(ErrorProperties.IncludeAttribute.ON_PARAM);
this.errorProperties.setIncludeMessage(ErrorProperties.IncludeAttribute.ON_PARAM); this.errorProperties.setIncludeMessage(ErrorProperties.IncludeAttribute.ON_PARAM);
this.request.addParameter("trace", "true"); this.request.addParameter("trace", "true");
this.request.addParameter("message", "true"); this.request.addParameter("message", "true");
...@@ -97,7 +97,7 @@ class ManagementErrorEndpointTests { ...@@ -97,7 +97,7 @@ class ManagementErrorEndpointTests {
@Test @Test
void errorResponseParamsFalse() { void errorResponseParamsFalse() {
this.errorProperties.setIncludeStacktrace(ErrorProperties.IncludeStacktrace.ON_PARAM); this.errorProperties.setIncludeStacktrace(ErrorProperties.IncludeAttribute.ON_PARAM);
this.errorProperties.setIncludeMessage(ErrorProperties.IncludeAttribute.ON_PARAM); this.errorProperties.setIncludeMessage(ErrorProperties.IncludeAttribute.ON_PARAM);
this.request.addParameter("trace", "false"); this.request.addParameter("trace", "false");
this.request.addParameter("message", "false"); this.request.addParameter("message", "false");
......
...@@ -43,7 +43,7 @@ public class ErrorProperties { ...@@ -43,7 +43,7 @@ public class ErrorProperties {
/** /**
* When to include the "trace" attribute. * When to include the "trace" attribute.
*/ */
private IncludeStacktrace includeStacktrace = IncludeStacktrace.NEVER; private IncludeAttribute includeStacktrace = IncludeAttribute.NEVER;
/** /**
* When to include "message" attribute. * When to include "message" attribute.
...@@ -73,11 +73,11 @@ public class ErrorProperties { ...@@ -73,11 +73,11 @@ public class ErrorProperties {
this.includeException = includeException; this.includeException = includeException;
} }
public IncludeStacktrace getIncludeStacktrace() { public IncludeAttribute getIncludeStacktrace() {
return this.includeStacktrace; return this.includeStacktrace;
} }
public void setIncludeStacktrace(IncludeStacktrace includeStacktrace) { public void setIncludeStacktrace(IncludeAttribute includeStacktrace) {
this.includeStacktrace = includeStacktrace; this.includeStacktrace = includeStacktrace;
} }
...@@ -101,34 +101,6 @@ public class ErrorProperties { ...@@ -101,34 +101,6 @@ public class ErrorProperties {
return this.whitelabel; return this.whitelabel;
} }
/**
* Include Stacktrace attribute options.
*/
public enum IncludeStacktrace {
/**
* Never add stacktrace information.
*/
NEVER,
/**
* Always add stacktrace information.
*/
ALWAYS,
/**
* Add error attribute when the appropriate request parameter is "true".
*/
ON_PARAM,
/**
* Add stacktrace information when the "trace" request parameter is "true".
*/
@Deprecated // since 2.3.0 in favor of {@link #ON_PARAM}
ON_TRACE_PARAM;
}
/** /**
* Include error attributes options. * Include error attributes options.
*/ */
......
...@@ -29,7 +29,7 @@ import org.apache.coyote.ProtocolHandler; ...@@ -29,7 +29,7 @@ import org.apache.coyote.ProtocolHandler;
import org.apache.coyote.http11.AbstractHttp11Protocol; import org.apache.coyote.http11.AbstractHttp11Protocol;
import org.springframework.boot.autoconfigure.web.ErrorProperties; import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeStacktrace; import org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeAttribute;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat.Accesslog; import org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat.Accesslog;
import org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat.Remoteip; import org.springframework.boot.autoconfigure.web.ServerProperties.Tomcat.Remoteip;
...@@ -292,7 +292,7 @@ public class TomcatWebServerFactoryCustomizer ...@@ -292,7 +292,7 @@ public class TomcatWebServerFactoryCustomizer
} }
private void customizeErrorReportValve(ErrorProperties error, ConfigurableTomcatWebServerFactory factory) { private void customizeErrorReportValve(ErrorProperties error, ConfigurableTomcatWebServerFactory factory) {
if (error.getIncludeStacktrace() == IncludeStacktrace.NEVER) { if (error.getIncludeStacktrace() == IncludeAttribute.NEVER) {
factory.addContextCustomizers((context) -> { factory.addContextCustomizers((context) -> {
ErrorReportValve valve = new ErrorReportValve(); ErrorReportValve valve = new ErrorReportValve();
valve.setShowServerInfo(false); valve.setShowServerInfo(false);
......
...@@ -187,13 +187,11 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa ...@@ -187,13 +187,11 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
* @param produces the media type produced (or {@code MediaType.ALL}) * @param produces the media type produced (or {@code MediaType.ALL})
* @return if the stacktrace attribute should be included * @return if the stacktrace attribute should be included
*/ */
@SuppressWarnings("deprecation")
protected boolean isIncludeStackTrace(ServerRequest request, MediaType produces) { protected boolean isIncludeStackTrace(ServerRequest request, MediaType produces) {
switch (this.errorProperties.getIncludeStacktrace()) { switch (this.errorProperties.getIncludeStacktrace()) {
case ALWAYS: case ALWAYS:
return true; return true;
case ON_PARAM: case ON_PARAM:
case ON_TRACE_PARAM:
return isTraceEnabled(request); return isTraceEnabled(request);
default: default:
return false; return false;
......
...@@ -136,13 +136,11 @@ public class BasicErrorController extends AbstractErrorController { ...@@ -136,13 +136,11 @@ public class BasicErrorController extends AbstractErrorController {
* @param produces the media type produced (or {@code MediaType.ALL}) * @param produces the media type produced (or {@code MediaType.ALL})
* @return if the stacktrace attribute should be included * @return if the stacktrace attribute should be included
*/ */
@SuppressWarnings("deprecation")
protected boolean isIncludeStackTrace(HttpServletRequest request, MediaType produces) { protected boolean isIncludeStackTrace(HttpServletRequest request, MediaType produces) {
switch (getErrorProperties().getIncludeStacktrace()) { switch (getErrorProperties().getIncludeStacktrace()) {
case ALWAYS: case ALWAYS:
return true; return true;
case ON_PARAM: case ON_PARAM:
case ON_TRACE_PARAM:
return getTraceParameter(request); return getTraceParameter(request);
default: default:
return false; return false;
......
...@@ -93,13 +93,6 @@ class BasicErrorControllerIntegrationTests { ...@@ -93,13 +93,6 @@ class BasicErrorControllerIntegrationTests {
assertThat(entity.getBody().containsKey("trace")).isFalse(); assertThat(entity.getBody().containsKey("trace")).isFalse();
} }
@Test
void testErrorForMachineClientWithTraceParamsTrue() {
load("--server.error.include-exception=true", "--server.error.include-stacktrace=on-trace-param",
"--server.error.include-message=on-param");
exceptionWithStackTraceAndMessage("?trace=true&message=true");
}
@Test @Test
void testErrorForMachineClientWithParamsTrue() { void testErrorForMachineClientWithParamsTrue() {
load("--server.error.include-exception=true", "--server.error.include-stacktrace=on-param", load("--server.error.include-exception=true", "--server.error.include-stacktrace=on-param",
......
...@@ -107,7 +107,7 @@ class DevToolPropertiesIntegrationTests { ...@@ -107,7 +107,7 @@ class DevToolPropertiesIntegrationTests {
this.context = getContext(application::run); this.context = getContext(application::run);
ConfigurableEnvironment environment = this.context.getEnvironment(); ConfigurableEnvironment environment = this.context.getEnvironment();
String includeStackTrace = environment.getProperty("server.error.include-stacktrace"); String includeStackTrace = environment.getProperty("server.error.include-stacktrace");
assertThat(includeStackTrace).isEqualTo(ErrorProperties.IncludeStacktrace.ALWAYS.toString()); assertThat(includeStackTrace).isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString());
String includeMessage = environment.getProperty("server.error.include-message"); String includeMessage = environment.getProperty("server.error.include-message");
assertThat(includeMessage).isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString()); assertThat(includeMessage).isEqualTo(ErrorProperties.IncludeAttribute.ALWAYS.toString());
} }
......
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