Merge branch '5.2.x'

# Conflicts:
#	build.gradle
#	spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java
#	spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java
This commit is contained in:
Juergen Hoeller
2020-06-06 18:52:51 +02:00
8 changed files with 43 additions and 43 deletions

View File

@@ -64,6 +64,8 @@ import org.springframework.web.util.UriTemplateHandler;
* @param <T> the body type
* @see #getMethod()
* @see #getUrl()
* @see org.springframework.web.client.RestOperations#exchange(RequestEntity, Class)
* @see ResponseEntity
*/
public class RequestEntity<T> extends HttpEntity<T> {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,6 +70,10 @@ import org.springframework.util.ObjectUtils;
* @since 3.0.2
* @param <T> the body type
* @see #getStatusCode()
* @see org.springframework.web.client.RestOperations#getForEntity(String, Class, Object...)
* @see org.springframework.web.client.RestOperations#getForEntity(String, Class, java.util.Map)
* @see org.springframework.web.client.RestOperations#getForEntity(URI, Class)
* @see RequestEntity
*/
public class ResponseEntity<T> extends HttpEntity<T> {
@@ -217,19 +221,6 @@ public class ResponseEntity<T> extends HttpEntity<T> {
return new DefaultBuilder(status);
}
/**
* A shortcut for creating a {@code ResponseEntity} with the given body
* and the {@linkplain HttpStatus#OK OK} status, or an empty body and a
* {@linkplain HttpStatus#NOT_FOUND NOT FOUND} status in case of an
* {@linkplain Optional#empty()} parameter.
* @return the created {@code ResponseEntity}
* @since 5.1
*/
public static <T> ResponseEntity<T> of(Optional<T> body) {
Assert.notNull(body, "Body must not be null");
return body.map(ResponseEntity::ok).orElse(notFound().build());
}
/**
* Create a builder with the status set to {@linkplain HttpStatus#OK OK}.
* @return the created builder
@@ -246,8 +237,20 @@ public class ResponseEntity<T> extends HttpEntity<T> {
* @since 4.1
*/
public static <T> ResponseEntity<T> ok(T body) {
BodyBuilder builder = ok();
return builder.body(body);
return ok().body(body);
}
/**
* A shortcut for creating a {@code ResponseEntity} with the given body
* and the {@linkplain HttpStatus#OK OK} status, or an empty body and a
* {@linkplain HttpStatus#NOT_FOUND NOT FOUND} status in case of an
* {@linkplain Optional#empty()} parameter.
* @return the created {@code ResponseEntity}
* @since 5.1
*/
public static <T> ResponseEntity<T> of(Optional<T> body) {
Assert.notNull(body, "Body must not be null");
return body.map(ResponseEntity::ok).orElseGet(() -> notFound().build());
}
/**
@@ -258,8 +261,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
* @since 4.1
*/
public static BodyBuilder created(URI location) {
BodyBuilder builder = status(HttpStatus.CREATED);
return builder.location(location);
return status(HttpStatus.CREATED).location(location);
}
/**