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
dd086600
Commit
dd086600
authored
Apr 04, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add text/plain error response support"
This reverts commit
23892e33
.
parent
7242ddae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
37 deletions
+6
-37
BasicErrorController.java
...ramework/boot/autoconfigure/web/BasicErrorController.java
+6
-23
BasicErrorControllerIntegrationTests.java
...toconfigure/web/BasicErrorControllerIntegrationTests.java
+0
-14
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java
View file @
dd086600
...
@@ -31,6 +31,7 @@ import org.springframework.http.ResponseEntity;
...
@@ -31,6 +31,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
/**
/**
...
@@ -81,16 +82,6 @@ public class BasicErrorController extends AbstractErrorController {
...
@@ -81,16 +82,6 @@ public class BasicErrorController extends AbstractErrorController {
return
this
.
errorProperties
.
getPath
();
return
this
.
errorProperties
.
getPath
();
}
}
@RequestMapping
(
produces
=
{
"application/xml"
,
"text/xml"
,
"application/json"
,
"application/*+xml"
,
"application/*+json"
})
public
ResponseEntity
<
Map
<
String
,
Object
>>
errorStructured
(
HttpServletRequest
request
)
{
Map
<
String
,
Object
>
body
=
getErrorAttributes
(
request
,
isIncludeStackTrace
(
request
,
MediaType
.
ALL
));
HttpStatus
status
=
getStatus
(
request
);
return
new
ResponseEntity
<
Map
<
String
,
Object
>>(
body
,
status
);
}
@RequestMapping
(
produces
=
"text/html"
)
@RequestMapping
(
produces
=
"text/html"
)
public
ModelAndView
errorHtml
(
HttpServletRequest
request
,
public
ModelAndView
errorHtml
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
HttpServletResponse
response
)
{
...
@@ -103,20 +94,12 @@ public class BasicErrorController extends AbstractErrorController {
...
@@ -103,20 +94,12 @@ public class BasicErrorController extends AbstractErrorController {
}
}
@RequestMapping
@RequestMapping
public
ResponseEntity
<
String
>
errorText
(
HttpServletRequest
request
)
{
@ResponseBody
Map
<
String
,
Object
>
attributes
=
getErrorAttributes
(
request
,
public
ResponseEntity
<
Map
<
String
,
Object
>>
error
(
HttpServletRequest
request
)
{
isIncludeStackTrace
(
request
,
MediaType
.
TEXT_PLAIN
));
Map
<
String
,
Object
>
body
=
getErrorAttributes
(
request
,
int
padding
=
0
;
isIncludeStackTrace
(
request
,
MediaType
.
ALL
));
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
attributes
.
entrySet
())
{
padding
=
Math
.
max
(
padding
,
entry
.
getKey
().
length
());
}
StringBuffer
body
=
new
StringBuffer
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
attributes
.
entrySet
())
{
body
.
append
(
String
.
format
(
"%-"
+
padding
+
"s : %s%n"
,
entry
.
getKey
(),
entry
.
getValue
()));
}
HttpStatus
status
=
getStatus
(
request
);
HttpStatus
status
=
getStatus
(
request
);
return
new
ResponseEntity
<
String
>(
body
.
toString
()
,
status
);
return
new
ResponseEntity
<
Map
<
String
,
Object
>>(
body
,
status
);
}
}
/**
/**
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java
View file @
dd086600
...
@@ -158,7 +158,6 @@ public class BasicErrorControllerIntegrationTests {
...
@@ -158,7 +158,6 @@ public class BasicErrorControllerIntegrationTests {
load
();
load
();
RequestEntity
request
=
RequestEntity
RequestEntity
request
=
RequestEntity
.
post
(
URI
.
create
(
createUrl
(
"/bodyValidation"
)))
.
post
(
URI
.
create
(
createUrl
(
"/bodyValidation"
)))
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
contentType
(
MediaType
.
APPLICATION_JSON
).
body
(
"{}"
);
.
contentType
(
MediaType
.
APPLICATION_JSON
).
body
(
"{}"
);
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
exchange
(
request
,
Map
.
class
);
ResponseEntity
<
Map
>
entity
=
new
TestRestTemplate
().
exchange
(
request
,
Map
.
class
);
String
resp
=
entity
.
getBody
().
toString
();
String
resp
=
entity
.
getBody
().
toString
();
...
@@ -168,19 +167,6 @@ public class BasicErrorControllerIntegrationTests {
...
@@ -168,19 +167,6 @@ public class BasicErrorControllerIntegrationTests {
assertThat
(
resp
).
contains
(
MethodArgumentNotValidException
.
class
.
getName
());
assertThat
(
resp
).
contains
(
MethodArgumentNotValidException
.
class
.
getName
());
}
}
@Test
public
void
testRequestBodyValidationForText
()
throws
Exception
{
load
();
RequestEntity
<
Void
>
request
=
RequestEntity
.
post
(
URI
.
create
(
createUrl
(
"/"
)))
.
accept
(
MediaType
.
TEXT_PLAIN
).
build
();
ResponseEntity
<
String
>
entity
=
new
TestRestTemplate
().
exchange
(
request
,
String
.
class
);
String
resp
=
entity
.
getBody
().
toString
();
assertThat
(
resp
).
contains
(
"status"
);
assertThat
(
resp
).
contains
(
"error"
);
assertThat
(
resp
).
contains
(
IllegalStateException
.
class
.
getName
());
}
@Test
@Test
public
void
testConventionTemplateMapping
()
throws
Exception
{
public
void
testConventionTemplateMapping
()
throws
Exception
{
load
();
load
();
...
...
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