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
31253d0d
Commit
31253d0d
authored
Nov 19, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1931 from juzer/master
* pull1931: Fixed potential ClassCastException getting error
parents
c34cfb27
428d2caa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
DefaultErrorAttributes.java
...mework/boot/autoconfigure/web/DefaultErrorAttributes.java
+1
-1
DefaultErrorAttributesTests.java
...k/boot/autoconfigure/web/DefaultErrorAttributesTests.java
+13
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DefaultErrorAttributes.java
View file @
31253d0d
...
...
@@ -163,7 +163,7 @@ public class DefaultErrorAttributes implements ErrorAttributes, HandlerException
@Override
public
Throwable
getError
(
RequestAttributes
requestAttributes
)
{
Exception
exception
=
getAttribute
(
requestAttributes
,
ERROR_ATTRIBUTE
);
Throwable
exception
=
getAttribute
(
requestAttributes
,
ERROR_ATTRIBUTE
);
if
(
exception
==
null
)
{
exception
=
getAttribute
(
requestAttributes
,
"javax.servlet.error.exception"
);
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DefaultErrorAttributesTests.java
View file @
31253d0d
...
...
@@ -144,6 +144,19 @@ public class DefaultErrorAttributesTests {
assertThat
(
attributes
.
get
(
"message"
),
equalTo
((
Object
)
"Test"
));
}
@Test
public
void
getError
()
throws
Exception
{
Error
error
=
new
OutOfMemoryError
(
"Test error"
);
this
.
request
.
setAttribute
(
"javax.servlet.error.exception"
,
error
);
Map
<
String
,
Object
>
attributes
=
this
.
errorAttributes
.
getErrorAttributes
(
this
.
requestAttributes
,
false
);
assertThat
(
this
.
errorAttributes
.
getError
(
this
.
requestAttributes
),
sameInstance
((
Object
)
error
));
assertThat
(
attributes
.
get
(
"exception"
),
equalTo
((
Object
)
OutOfMemoryError
.
class
.
getName
()));
assertThat
(
attributes
.
get
(
"message"
),
equalTo
((
Object
)
"Test error"
));
}
@Test
public
void
extractBindingResultErrors
()
throws
Exception
{
BindingResult
bindingResult
=
new
MapBindingResult
(
Collections
.
singletonMap
(
"a"
,
...
...
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