From 1721aeccb0c7532429c1d5bfc3571ceb1126835c Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 30 Jan 2020 22:08:15 +0900 Subject: [PATCH] Use ServerHttpResponse.getRawStatusCode() in WebFluxTags See gh-19987 --- .../actuate/metrics/web/reactive/server/WebFluxTags.java | 9 +++------ .../metrics/web/reactive/server/WebFluxTagsTests.java | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java index 412b3c6520..ecbcf6ec70 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java @@ -22,7 +22,6 @@ import io.micrometer.core.instrument.Tag; 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; @@ -164,11 +163,9 @@ public final class WebFluxTags { 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; diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java index 0dd43e6e2f..fc82e9d902 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java @@ -21,8 +21,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; 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; @@ -123,9 +123,9 @@ class WebFluxTagsTests { 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);