Skip to content

Commit 3b235a0

Browse files
committed
Merge branch '5.1.x'
2 parents ac9a11a + 59064f0 commit 3b235a0

File tree

12 files changed

+32
-44
lines changed

12 files changed

+32
-44
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ext {
4848
slf4jVersion = "1.7.26" // spring-jcl + consistent 3rd party deps
4949
tiles3Version = "3.0.8"
5050
tomcatVersion = "9.0.22"
51-
undertowVersion = "2.0.22.Final"
51+
undertowVersion = "2.0.23.Final"
5252

5353
gradleScriptDir = "${rootProject.projectDir}/gradle"
5454
withoutJclOverSlf4j = {

spring-test/src/main/java/org/springframework/mock/http/client/reactive/MockClientHttpResponse.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public MockClientHttpResponse(int status) {
7171

7272
@Override
7373
public HttpStatus getStatusCode() {
74-
return HttpStatus.resolve(this.status);
74+
return HttpStatus.valueOf(this.status);
7575
}
7676

7777
@Override
@@ -81,10 +81,9 @@ public int getRawStatusCode() {
8181

8282
@Override
8383
public HttpHeaders getHeaders() {
84-
String headerName = HttpHeaders.SET_COOKIE;
85-
if (!getCookies().isEmpty() && this.headers.get(headerName) == null) {
84+
if (!getCookies().isEmpty() && this.headers.get(HttpHeaders.SET_COOKIE) == null) {
8685
getCookies().values().stream().flatMap(Collection::stream)
87-
.forEach(cookie -> getHeaders().add(headerName, cookie.toString()));
86+
.forEach(cookie -> getHeaders().add(HttpHeaders.SET_COOKIE, cookie.toString()));
8887
}
8988
return this.headers;
9089
}

spring-web/spring-web.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ dependencies {
8484
testRuntime("com.sun.xml.bind:jaxb-core:2.3.0.1")
8585
testRuntime("com.sun.xml.bind:jaxb-impl:2.3.0.1")
8686
testRuntime("javax.json:javax.json-api:1.1.4")
87-
testRuntime("org.apache.johnzon:johnzon-jsonb:1.1.11")
87+
testRuntime("org.apache.johnzon:johnzon-jsonb:1.1.12")
8888
}

spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,18 +35,19 @@
3535
public interface ClientHttpResponse extends HttpInputMessage, Closeable {
3636

3737
/**
38-
* Return the HTTP status code of the response.
39-
* @return the HTTP status as an HttpStatus enum value
38+
* Return the HTTP status code as an {@link HttpStatus} enum value.
39+
* @return the HTTP status as an HttpStatus enum value (never {@code null})
4040
* @throws IOException in case of I/O errors
4141
* @throws IllegalArgumentException in case of an unknown HTTP status code
42+
* @since #getRawStatusCode()
4243
* @see HttpStatus#valueOf(int)
4344
*/
4445
HttpStatus getStatusCode() throws IOException;
4546

4647
/**
4748
* Return the HTTP status code (potentially non-standard and not
4849
* resolvable through the {@link HttpStatus} enum) as an integer.
49-
* @return the HTTP status as an integer
50+
* @return the HTTP status as an integer value
5051
* @throws IOException in case of I/O errors
5152
* @since 3.1.1
5253
* @see #getStatusCode()

spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponse.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.springframework.http.HttpStatus;
2020
import org.springframework.http.ReactiveHttpInputMessage;
2121
import org.springframework.http.ResponseCookie;
22-
import org.springframework.lang.Nullable;
2322
import org.springframework.util.MultiValueMap;
2423

2524
/**
@@ -32,18 +31,18 @@
3231
public interface ClientHttpResponse extends ReactiveHttpInputMessage {
3332

3433
/**
35-
* Return the HTTP status code of the response.
36-
* @return the HTTP status as an HttpStatus enum value
34+
* Return the HTTP status code as an {@link HttpStatus} enum value.
35+
* @return the HTTP status as an HttpStatus enum value (never {@code null})
3736
* @throws IllegalArgumentException in case of an unknown HTTP status code
38-
* @see HttpStatus#resolve(int)
37+
* @since #getRawStatusCode()
38+
* @see HttpStatus#valueOf(int)
3939
*/
40-
@Nullable
4140
HttpStatus getStatusCode();
4241

4342
/**
4443
* Return the HTTP status code (potentially non-standard and not
4544
* resolvable through the {@link HttpStatus} enum) as an integer.
46-
* @return the HTTP status as an integer
45+
* @return the HTTP status as an integer value
4746
* @since 5.0.6
4847
* @see #getStatusCode()
4948
* @see HttpStatus#resolve(int)

spring-web/src/main/java/org/springframework/http/client/reactive/ClientHttpResponseDecorator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public ClientHttpResponse getDelegate() {
4848
}
4949

5050

51-
// ServerHttpResponse delegation methods...
51+
// ClientHttpResponse delegation methods...
5252

5353
@Override
5454
public HttpStatus getStatusCode() {

spring-web/src/main/java/org/springframework/http/client/reactive/JettyClientHttpResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public JettyClientHttpResponse(ReactiveResponse reactiveResponse, Publisher<Data
5353

5454
@Override
5555
public HttpStatus getStatusCode() {
56-
return HttpStatus.resolve(getRawStatusCode());
56+
return HttpStatus.valueOf(getRawStatusCode());
5757
}
5858

5959
@Override

spring-web/src/main/java/org/springframework/http/client/reactive/ReactorClientHttpResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public HttpHeaders getHeaders() {
8888

8989
@Override
9090
public HttpStatus getStatusCode() {
91-
return HttpStatus.resolve(getRawStatusCode());
91+
return HttpStatus.valueOf(getRawStatusCode());
9292
}
9393

9494
@Override

spring-web/src/test/java/org/springframework/mock/http/client/reactive/test/MockClientHttpResponse.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public MockClientHttpResponse(int status) {
7171

7272
@Override
7373
public HttpStatus getStatusCode() {
74-
return HttpStatus.resolve(this.status);
74+
return HttpStatus.valueOf(this.status);
7575
}
7676

7777
@Override
@@ -81,10 +81,9 @@ public int getRawStatusCode() {
8181

8282
@Override
8383
public HttpHeaders getHeaders() {
84-
String headerName = HttpHeaders.SET_COOKIE;
85-
if (!getCookies().isEmpty() && this.headers.get(headerName) == null) {
84+
if (!getCookies().isEmpty() && this.headers.get(HttpHeaders.SET_COOKIE) == null) {
8685
getCookies().values().stream().flatMap(Collection::stream)
87-
.forEach(cookie -> getHeaders().add(headerName, cookie.toString()));
86+
.forEach(cookie -> getHeaders().add(HttpHeaders.SET_COOKIE, cookie.toString()));
8887
}
8988
return this.headers;
9089
}

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.springframework.http.client.reactive.ClientHttpResponse;
3737
import org.springframework.http.codec.HttpMessageReader;
3838
import org.springframework.http.codec.HttpMessageWriter;
39-
import org.springframework.lang.Nullable;
4039
import org.springframework.util.MultiValueMap;
4140
import org.springframework.web.reactive.function.BodyExtractor;
4241

@@ -61,17 +60,17 @@
6160
public interface ClientResponse {
6261

6362
/**
64-
* Return the status code of this response.
65-
* @return the status as an HttpStatus enum value
63+
* Return the HTTP status code as an {@link HttpStatus} enum value.
64+
* @return the HTTP status as an HttpStatus enum value (never {@code null})
6665
* @throws IllegalArgumentException in case of an unknown HTTP status code
67-
* @see HttpStatus#resolve(int)
66+
* @since #getRawStatusCode()
67+
* @see HttpStatus#valueOf(int)
6868
*/
69-
@Nullable
7069
HttpStatus statusCode();
7170

7271
/**
7372
* Return the (potentially non-standard) status code of this response.
74-
* @return the status as an integer
73+
* @return the HTTP status as an integer value
7574
* @since 5.1
7675
* @see #statusCode()
7776
* @see HttpStatus#resolve(int)

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public BuiltClientHttpResponse(int statusCode, HttpHeaders headers,
203203

204204
@Override
205205
public HttpStatus getStatusCode() {
206-
return HttpStatus.resolve(this.statusCode);
206+
return HttpStatus.valueOf(this.statusCode);
207207
}
208208

209209
@Override

spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.nio.charset.StandardCharsets;
2020

21-
import org.junit.Before;
2221
import org.junit.Test;
2322
import reactor.core.publisher.Flux;
2423
import reactor.test.StepVerifier;
@@ -31,18 +30,15 @@
3130
import org.springframework.http.ResponseCookie;
3231

3332
import static org.assertj.core.api.Assertions.assertThat;
33+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
3434

3535
/**
3636
* @author Arjen Poutsma
3737
*/
3838
public class DefaultClientResponseBuilderTests {
3939

40-
private DataBufferFactory dataBufferFactory;
40+
private final DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
4141

42-
@Before
43-
public void createBufferFactory() {
44-
this.dataBufferFactory = new DefaultDataBufferFactory();
45-
}
4642

4743
@Test
4844
public void normal() {
@@ -102,16 +98,11 @@ public void from() {
10298

10399
@Test
104100
public void fromCustomStatus() {
105-
106-
ClientResponse other = ClientResponse.create(499, ExchangeStrategies.withDefaults())
107-
.build();
108-
109-
ClientResponse result = ClientResponse.from(other)
110-
.build();
101+
ClientResponse other = ClientResponse.create(499, ExchangeStrategies.withDefaults()).build();
102+
ClientResponse result = ClientResponse.from(other).build();
111103

112104
assertThat(result.rawStatusCode()).isEqualTo(499);
113-
assertThat(result.statusCode()).isNull();
105+
assertThatIllegalArgumentException().isThrownBy(result::statusCode);
114106
}
115107

116-
117108
}

0 commit comments

Comments
 (0)