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
e3b84786
Commit
e3b84786
authored
Apr 17, 2020
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
555132e0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
39 deletions
+36
-39
ManagementErrorEndpoint.java
...te/autoconfigure/web/servlet/ManagementErrorEndpoint.java
+10
-10
DefaultErrorWebExceptionHandler.java
...e/web/reactive/error/DefaultErrorWebExceptionHandler.java
+10
-10
BasicErrorController.java
...autoconfigure/web/servlet/error/BasicErrorController.java
+10
-12
DefaultErrorAttributes.java
...mework/boot/web/servlet/error/DefaultErrorAttributes.java
+5
-7
ErrorAttributes.java
...ringframework/boot/web/servlet/error/ErrorAttributes.java
+1
-0
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ManagementErrorEndpoint.java
View file @
e3b84786
...
@@ -57,25 +57,25 @@ public class ManagementErrorEndpoint {
...
@@ -57,25 +57,25 @@ public class ManagementErrorEndpoint {
}
}
private
boolean
includeStackTrace
(
ServletWebRequest
request
)
{
private
boolean
includeStackTrace
(
ServletWebRequest
request
)
{
ErrorProperties
.
IncludeStacktrace
include
=
this
.
errorProperties
.
getIncludeStacktrace
();
switch
(
this
.
errorProperties
.
getIncludeStacktrace
())
{
if
(
include
==
ErrorProperties
.
IncludeStacktrace
.
ALWAYS
)
{
case
ALWAYS:
return
true
;
return
true
;
}
case
ON_TRACE_PARAM:
if
(
include
==
ErrorProperties
.
IncludeStacktrace
.
ON_TRACE_PARAM
)
{
return
getBooleanParameter
(
request
,
"trace"
);
return
getBooleanParameter
(
request
,
"trace"
);
default
:
return
false
;
}
}
return
false
;
}
}
private
boolean
includeDetails
(
ServletWebRequest
request
)
{
private
boolean
includeDetails
(
ServletWebRequest
request
)
{
ErrorProperties
.
IncludeDetails
include
=
this
.
errorProperties
.
getIncludeDetails
();
switch
(
this
.
errorProperties
.
getIncludeDetails
())
{
if
(
include
==
ErrorProperties
.
IncludeDetails
.
ALWAYS
)
{
case
ALWAYS:
return
true
;
return
true
;
}
case
ON_DETAILS_PARAM:
if
(
include
==
ErrorProperties
.
IncludeDetails
.
ON_DETAILS_PARAM
)
{
return
getBooleanParameter
(
request
,
"details"
);
return
getBooleanParameter
(
request
,
"details"
);
default
:
return
false
;
}
}
return
false
;
}
}
protected
boolean
getBooleanParameter
(
ServletWebRequest
request
,
String
parameterName
)
{
protected
boolean
getBooleanParameter
(
ServletWebRequest
request
,
String
parameterName
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java
View file @
e3b84786
...
@@ -156,14 +156,14 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
...
@@ -156,14 +156,14 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
* @return if the stacktrace attribute should be included
* @return if the stacktrace attribute should be included
*/
*/
protected
boolean
isIncludeStackTrace
(
ServerRequest
request
,
MediaType
produces
)
{
protected
boolean
isIncludeStackTrace
(
ServerRequest
request
,
MediaType
produces
)
{
ErrorProperties
.
IncludeStacktrace
include
=
this
.
errorProperties
.
getIncludeStacktrace
();
switch
(
this
.
errorProperties
.
getIncludeStacktrace
())
{
if
(
include
==
ErrorProperties
.
IncludeStacktrace
.
ALWAYS
)
{
case
ALWAYS:
return
true
;
return
true
;
}
case
ON_TRACE_PARAM:
if
(
include
==
ErrorProperties
.
IncludeStacktrace
.
ON_TRACE_PARAM
)
{
return
isTraceEnabled
(
request
);
return
isTraceEnabled
(
request
);
default
:
return
false
;
}
}
return
false
;
}
}
/**
/**
...
@@ -173,14 +173,14 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
...
@@ -173,14 +173,14 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
* @return if the message and errors attributes should be included
* @return if the message and errors attributes should be included
*/
*/
protected
boolean
isIncludeDetails
(
ServerRequest
request
,
MediaType
produces
)
{
protected
boolean
isIncludeDetails
(
ServerRequest
request
,
MediaType
produces
)
{
ErrorProperties
.
IncludeDetails
include
=
this
.
errorProperties
.
getIncludeDetails
();
switch
(
this
.
errorProperties
.
getIncludeDetails
())
{
if
(
include
==
ErrorProperties
.
IncludeDetails
.
ALWAYS
)
{
case
ALWAYS:
return
true
;
return
true
;
}
case
ON_DETAILS_PARAM:
if
(
include
==
ErrorProperties
.
IncludeDetails
.
ON_DETAILS_PARAM
)
{
return
isDetailsEnabled
(
request
);
return
isDetailsEnabled
(
request
);
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 @
e3b84786
...
@@ -24,8 +24,6 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -24,8 +24,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.boot.autoconfigure.web.ErrorProperties
;
import
org.springframework.boot.autoconfigure.web.ErrorProperties
;
import
org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeDetails
;
import
org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeStacktrace
;
import
org.springframework.boot.web.servlet.error.ErrorAttributes
;
import
org.springframework.boot.web.servlet.error.ErrorAttributes
;
import
org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory
;
import
org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -120,14 +118,14 @@ public class BasicErrorController extends AbstractErrorController {
...
@@ -120,14 +118,14 @@ public class BasicErrorController extends AbstractErrorController {
* @return if the stacktrace attribute should be included
* @return if the stacktrace attribute should be included
*/
*/
protected
boolean
isIncludeStackTrace
(
HttpServletRequest
request
,
MediaType
produces
)
{
protected
boolean
isIncludeStackTrace
(
HttpServletRequest
request
,
MediaType
produces
)
{
IncludeStacktrace
include
=
getErrorProperties
().
getIncludeStacktrace
();
switch
(
getErrorProperties
().
getIncludeStacktrace
())
{
if
(
include
==
IncludeStacktrace
.
ALWAYS
)
{
case
ALWAYS:
return
true
;
return
true
;
}
case
ON_TRACE_PARAM:
if
(
include
==
IncludeStacktrace
.
ON_TRACE_PARAM
)
{
return
getTraceParameter
(
request
);
return
getTraceParameter
(
request
);
default
:
return
false
;
}
}
return
false
;
}
}
/**
/**
...
@@ -137,14 +135,14 @@ public class BasicErrorController extends AbstractErrorController {
...
@@ -137,14 +135,14 @@ public class BasicErrorController extends AbstractErrorController {
* @return if the error details attributes should be included
* @return if the error details attributes should be included
*/
*/
protected
boolean
isIncludeDetails
(
HttpServletRequest
request
,
MediaType
produces
)
{
protected
boolean
isIncludeDetails
(
HttpServletRequest
request
,
MediaType
produces
)
{
IncludeDetails
include
=
getErrorProperties
().
getIncludeDetails
();
switch
(
getErrorProperties
().
getIncludeDetails
())
{
if
(
include
==
IncludeDetails
.
ALWAYS
)
{
case
ALWAYS:
return
true
;
return
true
;
}
case
ON_DETAILS_PARAM:
if
(
include
==
IncludeDetails
.
ON_DETAILS_PARAM
)
{
return
getDetailsParameter
(
request
);
return
getDetailsParameter
(
request
);
default
:
return
false
;
}
}
return
false
;
}
}
/**
/**
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/error/DefaultErrorAttributes.java
View file @
e3b84786
...
@@ -22,6 +22,7 @@ import java.util.Date;
...
@@ -22,6 +22,7 @@ import java.util.Date;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
javax.servlet.RequestDispatcher
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -118,7 +119,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
...
@@ -118,7 +119,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
}
}
private
void
addStatus
(
Map
<
String
,
Object
>
errorAttributes
,
RequestAttributes
requestAttributes
)
{
private
void
addStatus
(
Map
<
String
,
Object
>
errorAttributes
,
RequestAttributes
requestAttributes
)
{
Integer
status
=
getAttribute
(
requestAttributes
,
"javax.servlet.error.status_code"
);
Integer
status
=
getAttribute
(
requestAttributes
,
RequestDispatcher
.
ERROR_STATUS_CODE
);
if
(
status
==
null
)
{
if
(
status
==
null
)
{
errorAttributes
.
put
(
"status"
,
999
);
errorAttributes
.
put
(
"status"
,
999
);
errorAttributes
.
put
(
"error"
,
"None"
);
errorAttributes
.
put
(
"error"
,
"None"
);
...
@@ -168,7 +169,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
...
@@ -168,7 +169,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
errorAttributes
.
put
(
"message"
,
"An error occurred while processing the request"
);
errorAttributes
.
put
(
"message"
,
"An error occurred while processing the request"
);
return
;
return
;
}
}
Object
message
=
getAttribute
(
webRequest
,
"javax.servlet.error.message"
);
Object
message
=
getAttribute
(
webRequest
,
RequestDispatcher
.
ERROR_MESSAGE
);
if
(
StringUtils
.
isEmpty
(
message
)
&&
error
!=
null
)
{
if
(
StringUtils
.
isEmpty
(
message
)
&&
error
!=
null
)
{
message
=
error
.
getMessage
();
message
=
error
.
getMessage
();
}
}
...
@@ -209,7 +210,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
...
@@ -209,7 +210,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
}
}
private
void
addPath
(
Map
<
String
,
Object
>
errorAttributes
,
RequestAttributes
requestAttributes
)
{
private
void
addPath
(
Map
<
String
,
Object
>
errorAttributes
,
RequestAttributes
requestAttributes
)
{
String
path
=
getAttribute
(
requestAttributes
,
"javax.servlet.error.request_uri"
);
String
path
=
getAttribute
(
requestAttributes
,
RequestDispatcher
.
ERROR_REQUEST_URI
);
if
(
path
!=
null
)
{
if
(
path
!=
null
)
{
errorAttributes
.
put
(
"path"
,
path
);
errorAttributes
.
put
(
"path"
,
path
);
}
}
...
@@ -218,10 +219,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
...
@@ -218,10 +219,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
@Override
@Override
public
Throwable
getError
(
WebRequest
webRequest
)
{
public
Throwable
getError
(
WebRequest
webRequest
)
{
Throwable
exception
=
getAttribute
(
webRequest
,
ERROR_ATTRIBUTE
);
Throwable
exception
=
getAttribute
(
webRequest
,
ERROR_ATTRIBUTE
);
if
(
exception
==
null
)
{
return
(
exception
!=
null
)
?
exception
:
getAttribute
(
webRequest
,
RequestDispatcher
.
ERROR_EXCEPTION
);
exception
=
getAttribute
(
webRequest
,
"javax.servlet.error.exception"
);
}
return
exception
;
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/error/ErrorAttributes.java
View file @
e3b84786
...
@@ -53,6 +53,7 @@ public interface ErrorAttributes {
...
@@ -53,6 +53,7 @@ public interface ErrorAttributes {
* @param includeStackTrace if stack trace elements should be included
* @param includeStackTrace if stack trace elements should be included
* @param includeDetails if message and errors elements should be included
* @param includeDetails if message and errors elements should be included
* @return a map of error attributes
* @return a map of error attributes
* @since 2.3.0
*/
*/
Map
<
String
,
Object
>
getErrorAttributes
(
WebRequest
webRequest
,
boolean
includeStackTrace
,
boolean
includeDetails
);
Map
<
String
,
Object
>
getErrorAttributes
(
WebRequest
webRequest
,
boolean
includeStackTrace
,
boolean
includeDetails
);
...
...
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