From a85e27c7cd391d4cbe1297857a8b4cbd0000cc69 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 3 Dec 2018 15:48:13 +0100 Subject: [PATCH] Further replace magic number by HttpStatus See gh-15130 --- .../metrics/web/servlet/WebMvcTags.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java index 0dd146ad57..dc838dec33 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java @@ -180,18 +180,20 @@ public final class WebMvcTags { */ public static Tag outcome(HttpServletResponse response) { if (response != null) { - int status = response.getStatus(); - if (status < 200) { - return OUTCOME_INFORMATIONAL; - } - if (status < 300) { - return OUTCOME_SUCCESS; - } - if (status < 400) { - return OUTCOME_REDIRECTION; - } - if (status < 500) { - return OUTCOME_CLIENT_ERROR; + HttpStatus status = extractStatus(response); + if (status != null) { + if (status.is1xxInformational()) { + return OUTCOME_INFORMATIONAL; + } + if (status.is2xxSuccessful()) { + return OUTCOME_SUCCESS; + } + if (status.is3xxRedirection()) { + return OUTCOME_REDIRECTION; + } + if (status.is4xxClientError()) { + return OUTCOME_CLIENT_ERROR; + } } return OUTCOME_SERVER_ERROR; }