Skip to content

Commit b159ef6

Browse files
committed
Make MockClientHttpResponse uses raw status code
This commit make sure that MockClientHttpResponse does not use HttpStatus, but the raw status code. Closes gh-23599
1 parent 9610100 commit b159ef6

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

spring-test/src/main/java/org/springframework/test/web/reactive/server/HttpHandlerConnector.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 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.
@@ -17,7 +17,6 @@
1717
package org.springframework.test.web.reactive.server;
1818

1919
import java.net.URI;
20-
import java.util.Optional;
2120
import java.util.function.Function;
2221

2322
import org.apache.commons.logging.Log;
@@ -31,7 +30,6 @@
3130
import org.springframework.http.HttpCookie;
3231
import org.springframework.http.HttpHeaders;
3332
import org.springframework.http.HttpMethod;
34-
import org.springframework.http.HttpStatus;
3533
import org.springframework.http.client.reactive.ClientHttpConnector;
3634
import org.springframework.http.client.reactive.ClientHttpRequest;
3735
import org.springframework.http.client.reactive.ClientHttpResponse;
@@ -121,8 +119,8 @@ private ServerHttpResponse prepareResponse(ServerHttpResponse response, ServerHt
121119
}
122120

123121
private ClientHttpResponse adaptResponse(MockServerHttpResponse response, Flux<DataBuffer> body) {
124-
HttpStatus status = Optional.ofNullable(response.getStatusCode()).orElse(HttpStatus.OK);
125-
MockClientHttpResponse clientResponse = new MockClientHttpResponse(status);
122+
Integer status = response.getStatusCodeValue();
123+
MockClientHttpResponse clientResponse = new MockClientHttpResponse((status != null) ? status : 200);
126124
clientResponse.getHeaders().putAll(response.getHeaders());
127125
clientResponse.getCookies().putAll(response.getCookies());
128126
clientResponse.setBody(body);

0 commit comments

Comments
 (0)