Skip to content

Commit 0524a82

Browse files
committed
Update unprocessableEntity to allow body
Issue: SPR-12515
1 parent 33fca4e commit 0524a82

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

spring-web/src/main/java/org/springframework/http/ResponseEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public static HeadersBuilder<?> notFound() {
252252
* @return the created builder
253253
* @since 4.1.3
254254
*/
255-
public static HeadersBuilder<?> unprocessableEntity() {
255+
public static BodyBuilder unprocessableEntity() {
256256
return status(HttpStatus.UNPROCESSABLE_ENTITY);
257257
}
258258

spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ public void notFound() throws URISyntaxException {
122122

123123
@Test
124124
public void unprocessableEntity() throws URISyntaxException {
125-
ResponseEntity<Void> responseEntity = ResponseEntity.unprocessableEntity().build();
125+
ResponseEntity<String> responseEntity = ResponseEntity.unprocessableEntity().body("error");
126126

127127
assertNotNull(responseEntity);
128128
assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, responseEntity.getStatusCode());
129-
assertNull(responseEntity.getBody());
129+
assertEquals("error", responseEntity.getBody());
130130
}
131131

132132
@Test

0 commit comments

Comments
 (0)