Skip to content

Commit

Permalink
Use ServerHttpResponse.getRawStatusCode() in WebFluxTags
Browse files Browse the repository at this point in the history
This commit also changes Spring Framework version to 5.2.4.BUILD-SNAPSHOT for the necessary upstream change.

See spring-projects#19367 (comment)
  • Loading branch information
izeye committed Jan 30, 2020
1 parent 02d095d commit e111d8b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import org.springframework.boot.actuate.metrics.http.Outcome;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.AbstractServerHttpResponse;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.util.StringUtils;
import org.springframework.web.reactive.HandlerMapping;
Expand Down Expand Up @@ -164,11 +163,9 @@ public static Tag outcome(ServerWebExchange exchange) {

private static Integer extractStatusCode(ServerWebExchange exchange) {
ServerHttpResponse response = exchange.getResponse();
if (response instanceof AbstractServerHttpResponse) {
Integer statusCode = ((AbstractServerHttpResponse) response).getStatusCodeValue();
if (statusCode != null) {
return statusCode;
}
Integer statusCode = response.getRawStatusCode();
if (statusCode != null) {
return statusCode;
}
HttpStatus status = response.getStatusCode();
return (status != null) ? status.value() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.AbstractServerHttpResponse;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.web.server.MockServerWebExchange;
import org.springframework.web.reactive.HandlerMapping;
Expand Down Expand Up @@ -123,9 +124,9 @@ void outcomeTagIsSuccessWhenResponseStatusIsNull() {
void outcomeTagIsSuccessWhenResponseStatusIsAvailableFromUnderlyingServer() {
ServerWebExchange exchange = mock(ServerWebExchange.class);
ServerHttpRequest request = mock(ServerHttpRequest.class);
AbstractServerHttpResponse response = mock(AbstractServerHttpResponse.class);
ServerHttpResponse response = mock(ServerHttpResponse.class);
given(response.getStatusCode()).willReturn(HttpStatus.OK);
given(response.getStatusCodeValue()).willReturn(null);
given(response.getRawStatusCode()).willReturn(null);
given(exchange.getRequest()).willReturn(request);
given(exchange.getResponse()).willReturn(response);
Tag tag = WebFluxTags.outcome(exchange);
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-project/spring-boot-dependencies/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ bom {
]
}
}
library("Spring Framework", "5.2.3.RELEASE") {
library("Spring Framework", "5.2.4.BUILD-SNAPSHOT") {
group("org.springframework") {
imports = [
"spring-framework-bom"
Expand Down

0 comments on commit e111d8b

Please sign in to comment.