Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
e4618cfb
Commit
e4618cfb
authored
Dec 24, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete ErrorProperties.IncludeStacktrace
Closes gh-21286
parent
1a2577a0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
10 additions
and
51 deletions
+10
-51
ManagementErrorEndpoint.java
...te/autoconfigure/web/servlet/ManagementErrorEndpoint.java
+0
-2
ManagementErrorEndpointTests.java
...toconfigure/web/servlet/ManagementErrorEndpointTests.java
+4
-4
ErrorProperties.java
...ringframework/boot/autoconfigure/web/ErrorProperties.java
+3
-31
TomcatWebServerFactoryCustomizer.java
...figure/web/embedded/TomcatWebServerFactoryCustomizer.java
+2
-2
DefaultErrorWebExceptionHandler.java
...e/web/reactive/error/DefaultErrorWebExceptionHandler.java
+0
-2
BasicErrorController.java
...autoconfigure/web/servlet/error/BasicErrorController.java
+0
-2
BasicErrorControllerIntegrationTests.java
...b/servlet/error/BasicErrorControllerIntegrationTests.java
+0
-7
DevToolPropertiesIntegrationTests.java
.../boot/devtools/env/DevToolPropertiesIntegrationTests.java
+1
-1
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ManagementErrorEndpoint.java
View file @
e4618cfb
...
@@ -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
;
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ManagementErrorEndpointTests.java
View file @
e4618cfb
...
@@ -61,7 +61,7 @@ class ManagementErrorEndpointTests {
...
@@ -61,7 +61,7 @@ class ManagementErrorEndpointTests {
@Test
@Test
void
errorResponseAlwaysDetails
()
{
void
errorResponseAlwaysDetails
()
{
this
.
errorProperties
.
setIncludeStacktrace
(
ErrorProperties
.
Include
Stacktrac
e
.
ALWAYS
);
this
.
errorProperties
.
setIncludeStacktrace
(
ErrorProperties
.
Include
Attribut
e
.
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
.
Include
Stacktrac
e
.
ON_PARAM
);
this
.
errorProperties
.
setIncludeStacktrace
(
ErrorProperties
.
Include
Attribut
e
.
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
.
Include
Stacktrac
e
.
ON_PARAM
);
this
.
errorProperties
.
setIncludeStacktrace
(
ErrorProperties
.
Include
Attribut
e
.
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
.
Include
Stacktrac
e
.
ON_PARAM
);
this
.
errorProperties
.
setIncludeStacktrace
(
ErrorProperties
.
Include
Attribut
e
.
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"
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorProperties.java
View file @
e4618cfb
...
@@ -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
Include
Stacktrace
includeStacktrace
=
IncludeStacktrac
e
.
NEVER
;
private
Include
Attribute
includeStacktrace
=
IncludeAttribut
e
.
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
Include
Stacktrac
e
getIncludeStacktrace
()
{
public
Include
Attribut
e
getIncludeStacktrace
()
{
return
this
.
includeStacktrace
;
return
this
.
includeStacktrace
;
}
}
public
void
setIncludeStacktrace
(
Include
Stacktrac
e
includeStacktrace
)
{
public
void
setIncludeStacktrace
(
Include
Attribut
e
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.
*/
*/
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java
View file @
e4618cfb
...
@@ -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.Include
Stacktrac
e
;
import
org.springframework.boot.autoconfigure.web.ErrorProperties.Include
Attribut
e
;
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
()
==
Include
Stacktrac
e
.
NEVER
)
{
if
(
error
.
getIncludeStacktrace
()
==
Include
Attribut
e
.
NEVER
)
{
factory
.
addContextCustomizers
((
context
)
->
{
factory
.
addContextCustomizers
((
context
)
->
{
ErrorReportValve
valve
=
new
ErrorReportValve
();
ErrorReportValve
valve
=
new
ErrorReportValve
();
valve
.
setShowServerInfo
(
false
);
valve
.
setShowServerInfo
(
false
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java
View file @
e4618cfb
...
@@ -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
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java
View file @
e4618cfb
...
@@ -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
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java
View file @
e4618cfb
...
@@ -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"
,
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/env/DevToolPropertiesIntegrationTests.java
View file @
e4618cfb
...
@@ -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
.
Include
Stacktrac
e
.
ALWAYS
.
toString
());
assertThat
(
includeStackTrace
).
isEqualTo
(
ErrorProperties
.
Include
Attribut
e
.
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
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment