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
2112e02e
Commit
2112e02e
authored
Apr 11, 2019
by
Brian Clozel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
Closes gh-15952
parent
2c20d01e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
13 deletions
+15
-13
AbstractErrorWebExceptionHandler.java
.../web/reactive/error/AbstractErrorWebExceptionHandler.java
+3
-2
DefaultErrorWebExceptionHandlerIntegrationTests.java
...rror/DefaultErrorWebExceptionHandlerIntegrationTests.java
+8
-8
DefaultErrorAttributes.java
...ework/boot/web/reactive/error/DefaultErrorAttributes.java
+2
-1
DefaultErrorAttributesTests.java
.../boot/web/reactive/error/DefaultErrorAttributesTests.java
+2
-2
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java
View file @
2112e02e
...
@@ -215,11 +215,12 @@ public abstract class AbstractErrorWebExceptionHandler
...
@@ -215,11 +215,12 @@ public abstract class AbstractErrorWebExceptionHandler
Date
timestamp
=
(
Date
)
error
.
get
(
"timestamp"
);
Date
timestamp
=
(
Date
)
error
.
get
(
"timestamp"
);
Object
message
=
error
.
get
(
"message"
);
Object
message
=
error
.
get
(
"message"
);
Object
trace
=
error
.
get
(
"trace"
);
Object
trace
=
error
.
get
(
"trace"
);
Object
logPrefix
=
error
.
get
(
"logPrefix
"
);
Object
requestId
=
error
.
get
(
"requestId
"
);
builder
.
append
(
"<html><body><h1>Whitelabel Error Page</h1>"
).
append
(
builder
.
append
(
"<html><body><h1>Whitelabel Error Page</h1>"
).
append
(
"<p>This application has no configured error view, so you are seeing this as a fallback.</p>"
)
"<p>This application has no configured error view, so you are seeing this as a fallback.</p>"
)
.
append
(
"<div id='created'>"
).
append
(
timestamp
).
append
(
"</div>"
)
.
append
(
"<div id='created'>"
).
append
(
timestamp
).
append
(
"</div>"
)
.
append
(
logPrefix
).
append
(
"<div>There was an unexpected error (type="
)
.
append
(
"<div>["
).
append
(
requestId
)
.
append
(
"] There was an unexpected error (type="
)
.
append
(
htmlEscape
(
error
.
get
(
"error"
))).
append
(
", status="
)
.
append
(
htmlEscape
(
error
.
get
(
"error"
))).
append
(
", status="
)
.
append
(
htmlEscape
(
error
.
get
(
"status"
))).
append
(
").</div>"
);
.
append
(
htmlEscape
(
error
.
get
(
"status"
))).
append
(
").</div>"
);
if
(
message
!=
null
)
{
if
(
message
!=
null
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
View file @
2112e02e
...
@@ -83,7 +83,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -83,7 +83,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
())
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
())
.
jsonPath
(
"path"
).
isEqualTo
((
"/"
)).
jsonPath
(
"message"
)
.
jsonPath
(
"path"
).
isEqualTo
((
"/"
)).
jsonPath
(
"message"
)
.
isEqualTo
(
"Expected!"
).
jsonPath
(
"exception"
).
doesNotExist
()
.
isEqualTo
(
"Expected!"
).
jsonPath
(
"exception"
).
doesNotExist
()
.
jsonPath
(
"trace"
).
doesNotExist
().
jsonPath
(
"
logPrefix
"
)
.
jsonPath
(
"trace"
).
doesNotExist
().
jsonPath
(
"
requestId
"
)
.
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
.
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
this
.
outputCapture
.
expect
(
Matchers
.
allOf
(
this
.
outputCapture
.
expect
(
Matchers
.
allOf
(
containsString
(
"500 Server Error for HTTP GET \"/\""
),
containsString
(
"500 Server Error for HTTP GET \"/\""
),
...
@@ -99,7 +99,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -99,7 +99,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
expectBody
().
jsonPath
(
"status"
).
isEqualTo
(
"404"
).
jsonPath
(
"error"
)
.
expectBody
().
jsonPath
(
"status"
).
isEqualTo
(
"404"
).
jsonPath
(
"error"
)
.
isEqualTo
(
HttpStatus
.
NOT_FOUND
.
getReasonPhrase
()).
jsonPath
(
"path"
)
.
isEqualTo
(
HttpStatus
.
NOT_FOUND
.
getReasonPhrase
()).
jsonPath
(
"path"
)
.
isEqualTo
((
"/notFound"
)).
jsonPath
(
"exception"
).
doesNotExist
()
.
isEqualTo
((
"/notFound"
)).
jsonPath
(
"exception"
).
doesNotExist
()
.
jsonPath
(
"
logPrefix
"
).
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
.
jsonPath
(
"
requestId
"
).
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
});
});
}
}
...
@@ -128,7 +128,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -128,7 +128,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
isEqualTo
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
()).
jsonPath
(
"path"
)
.
isEqualTo
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
()).
jsonPath
(
"path"
)
.
isEqualTo
((
"/bind"
)).
jsonPath
(
"exception"
).
doesNotExist
()
.
isEqualTo
((
"/bind"
)).
jsonPath
(
"exception"
).
doesNotExist
()
.
jsonPath
(
"errors"
).
isArray
().
jsonPath
(
"message"
).
isNotEmpty
()
.
jsonPath
(
"errors"
).
isArray
().
jsonPath
(
"message"
).
isNotEmpty
()
.
jsonPath
(
"
logPrefix
"
).
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
.
jsonPath
(
"
requestId
"
).
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
});
});
}
}
...
@@ -145,7 +145,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -145,7 +145,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
())
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
())
.
jsonPath
(
"exception"
)
.
jsonPath
(
"exception"
)
.
isEqualTo
(
IllegalStateException
.
class
.
getName
())
.
isEqualTo
(
IllegalStateException
.
class
.
getName
())
.
jsonPath
(
"trace"
).
exists
().
jsonPath
(
"
logPrefix
"
)
.
jsonPath
(
"trace"
).
exists
().
jsonPath
(
"
requestId
"
)
.
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
.
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
});
});
}
}
...
@@ -161,7 +161,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -161,7 +161,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
())
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
())
.
jsonPath
(
"exception"
)
.
jsonPath
(
"exception"
)
.
isEqualTo
(
IllegalStateException
.
class
.
getName
())
.
isEqualTo
(
IllegalStateException
.
class
.
getName
())
.
jsonPath
(
"trace"
).
exists
().
jsonPath
(
"
logPrefix
"
)
.
jsonPath
(
"trace"
).
exists
().
jsonPath
(
"
requestId
"
)
.
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
.
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
});
});
}
}
...
@@ -177,7 +177,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -177,7 +177,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
())
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
())
.
jsonPath
(
"exception"
)
.
jsonPath
(
"exception"
)
.
isEqualTo
(
IllegalStateException
.
class
.
getName
())
.
isEqualTo
(
IllegalStateException
.
class
.
getName
())
.
jsonPath
(
"trace"
).
doesNotExist
().
jsonPath
(
"
logPrefix
"
)
.
jsonPath
(
"trace"
).
doesNotExist
().
jsonPath
(
"
requestId
"
)
.
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
.
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
});
});
}
}
...
@@ -193,7 +193,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -193,7 +193,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
.
isEqualTo
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
())
.
isEqualTo
(
HttpStatus
.
BAD_REQUEST
.
getReasonPhrase
())
.
jsonPath
(
"exception"
)
.
jsonPath
(
"exception"
)
.
isEqualTo
(
ResponseStatusException
.
class
.
getName
())
.
isEqualTo
(
ResponseStatusException
.
class
.
getName
())
.
jsonPath
(
"
logPrefix
"
).
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
.
jsonPath
(
"
requestId
"
).
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
});
});
}
}
...
@@ -326,7 +326,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
...
@@ -326,7 +326,7 @@ public class DefaultErrorWebExceptionHandlerIntegrationTests {
@Override
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
WebFilterChain
chain
)
{
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
WebFilterChain
chain
)
{
this
.
logId
=
exchange
.
get
LogPrefix
();
this
.
logId
=
exchange
.
get
Request
().
getId
();
return
chain
.
filter
(
exchange
);
return
chain
.
filter
(
exchange
);
}
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java
View file @
2112e02e
...
@@ -44,6 +44,7 @@ import org.springframework.web.server.ServerWebExchange;
...
@@ -44,6 +44,7 @@ import org.springframework.web.server.ServerWebExchange;
* <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>
* <li>path - The URL path when the exception was raised</li>
* <li>path - The URL path when the exception was raised</li>
* <li>requestId - Unique Id associated with the current request</li>
* </ul>
* </ul>
*
*
* @author Brian Clozel
* @author Brian Clozel
...
@@ -86,7 +87,7 @@ public class DefaultErrorAttributes implements ErrorAttributes {
...
@@ -86,7 +87,7 @@ public class DefaultErrorAttributes implements ErrorAttributes {
errorAttributes
.
put
(
"status"
,
errorStatus
.
value
());
errorAttributes
.
put
(
"status"
,
errorStatus
.
value
());
errorAttributes
.
put
(
"error"
,
errorStatus
.
getReasonPhrase
());
errorAttributes
.
put
(
"error"
,
errorStatus
.
getReasonPhrase
());
errorAttributes
.
put
(
"message"
,
determineMessage
(
error
));
errorAttributes
.
put
(
"message"
,
determineMessage
(
error
));
errorAttributes
.
put
(
"
logPrefix"
,
request
.
exchange
().
getLogPrefix
());
errorAttributes
.
put
(
"
requestId"
,
request
.
exchange
().
getRequest
().
getId
());
handleException
(
errorAttributes
,
determineException
(
error
),
includeStackTrace
);
handleException
(
errorAttributes
,
determineException
(
error
),
includeStackTrace
);
return
errorAttributes
;
return
errorAttributes
;
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributesTests.java
View file @
2112e02e
...
@@ -212,8 +212,8 @@ public class DefaultErrorAttributesTests {
...
@@ -212,8 +212,8 @@ public class DefaultErrorAttributesTests {
ServerRequest
serverRequest
=
buildServerRequest
(
request
,
NOT_FOUND
);
ServerRequest
serverRequest
=
buildServerRequest
(
request
,
NOT_FOUND
);
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
serverRequest
,
false
);
.
getErrorAttributes
(
serverRequest
,
false
);
assertThat
(
attributes
.
get
(
"
logPrefix
"
))
assertThat
(
attributes
.
get
(
"
requestId
"
))
.
isEqualTo
(
serverRequest
.
exchange
().
get
LogPrefix
());
.
isEqualTo
(
serverRequest
.
exchange
().
get
Request
().
getId
());
}
}
@Test
@Test
...
...
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